← All procedures

geo.areaSquareMeters

This function gives the area of a Polygon or a MultiPolygon on an ellipsoid, in square metres. An edge is a straight line in longitude and latitude, as RFC 7946 tells. The direction of a ring does not change the result.

CLI
Package
@procedures/geo · README
Path
["geo","areaSquareMeters"]
CLI
mark geo areaSquareMeters --polygon <object | object>
As data
{"$proc":["geo","areaSquareMeters"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/geo/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["geo","areaSquareMeters"], { polygon: "<polygon>" });
console.log(JSON.stringify(result));

From the command line

$ mark geo areaSquareMeters --polygon <object | object>

As data, in a program

{
  "$proc": ["geo", "areaSquareMeters"],
  "input": { "polygon": "<polygon>" }
}

Input

FieldTypeRequiredDefaultDescription
polygonobject | objectyesThe polygon. The holes of a polygon must be inside its exterior, and the polygons of a MultiPolygon must not overlap.
ellipsoidobjectnoThe ellipsoid. The default is `WGS84`.

Output

The schema does not list fields (number).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "polygon": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "Polygon"
              },
              "coordinates": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 2
                  }
                }
              },
              "bbox": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 6,
                    "maxItems": 6
                  }
                ],
                "description": "The bounding box of the object (RFC 7946, section 5)."
              }
            },
            "required": [
              "type",
              "coordinates"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "MultiPolygon"
              },
              "coordinates": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "array",
                      "items": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "number"
                        }
                      ],
                      "additionalItems": {},
                      "minItems": 2
                    }
                  }
                }
              },
              "bbox": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 6,
                    "maxItems": 6
                  }
                ],
                "description": "The bounding box of the object (RFC 7946, section 5)."
              }
            },
            "required": [
              "type",
              "coordinates"
            ],
            "additionalProperties": {}
          }
        ],
        "description": "The polygon. The holes of a polygon must be inside its exterior, and the polygons of a MultiPolygon\nmust not overlap."
      },
      "ellipsoid": {
        "type": "object",
        "properties": {
          "equatorialRadiusMeters": {
            "type": "number",
            "description": "The equatorial radius `a` in metres. It is a finite number more than 0."
          },
          "flattening": {
            "type": "number",
            "description": "The flattening `f`, equal to `(a - b) / a` for the polar radius `b`. It is a finite number less than 1. A negative flattening gives a prolate ellipsoid. The results are accurate for an absolute flattening of 1/50 or less."
          }
        },
        "required": [
          "equatorialRadiusMeters",
          "flattening"
        ],
        "additionalProperties": {},
        "description": "The ellipsoid. The default is `WGS84`."
      }
    },
    "required": [
      "polygon"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "number"
  }
}