← All procedures

geo.simplifyRegions

This function simplifies regions that share borders, for example the counties of a state, with the method of Douglas and Peucker. It gives one region for each region of the input, with the same type.

CLI
Package
@procedures/geo · README
Path
["geo","simplifyRegions"]
CLI
mark geo simplifyRegions --regions <object | object[]> --toleranceKm <number>
As data
{"$proc":["geo","simplifyRegions"],"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","simplifyRegions"], { regions: [], toleranceKm: 1 });
console.log(JSON.stringify(result));

From the command line

$ mark geo simplifyRegions --regions <object | object[]> --toleranceKm <number>

As data, in a program

{
  "$proc": ["geo", "simplifyRegions"],
  "input": { "regions": [], "toleranceKm": 1 }
}

Input

FieldTypeRequiredDefaultDescription
regionsobject | object[]yesThe Polygons and MultiPolygons. Regions that share a border must have equal positions on it.
toleranceKmnumberyesThe largest distance in kilometres from a removed position to the result, 0 or more.
radiusKmnumbernoThe radius of the sphere, more than 0. The default is `EARTH_MEAN_RADIUS_KM`.

Output

The schema does not list fields (object | object[]).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "regions": {
        "type": "array",
        "items": {
          "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 Polygons and MultiPolygons. Regions that share a border must have equal positions on it."
      },
      "toleranceKm": {
        "type": "number",
        "description": "The largest distance in kilometres from a removed position to the result, 0 or more."
      },
      "radiusKm": {
        "type": "number",
        "description": "The radius of the sphere, more than 0. The default is `EARTH_MEAN_RADIUS_KM`."
      }
    },
    "required": [
      "regions",
      "toleranceKm"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "array",
    "items": {
      "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": {}
        }
      ]
    }
  }
}