pygeoops.simplify#

pygeoops.simplify(geometry, tolerance: float, algorithm: str = 'rdp', lookahead: int = 8, preserve_topology: bool = True, preserve_common_boundaries=False, keep_points_on: BaseGeometry | None = None) BaseGeometry | ndarray[tuple[Any, ...], dtype[BaseGeometry]] | GeoSeries | None#

Simplify geometry/geometries.

Example of simplify on a polygon (grey: original, blue: simplified):

(Source code, png, hires.png, pdf)

../_images/simplify_basic.png
Parameters:
  • geometry (geometry or array_like) – a geometry or ndarray of geometries.

  • tolerance (float) –

    mandatory tolerance. The type of tolerance depends on the algorithm specified:

    • ”rdp”, “lang”, “lang+”: distance to use as tolerance

    • ”vw”: area to use as tolerance

  • algorithm (str, optional) –

    algorithm to use. Defaults to “rdp”. Possible values:

    • ”rdp”: Ramer Douglas Peuker algorithm

    • ”lang”: Lang algorithm

    • ”lang+”: Lang-based algorithm, but without limit of having at least nb_input_coordinates/lookahead points in the simplified output.

    • ”vw”: Visvalingal Whyatt algorithm

  • lookahead (int, optional) – the number of points to consider for removing in a moving window. Used for LANG algorithm. Defaults to 8.

  • preserve_topology (bool, optional) – True to (try to) return valid geometries as result. Defaults to True.

  • preserve_common_boundaries (bool, optional) – True to (try to) maintain common boundaries between all geometries in the input geometry list. Defaults to False.

  • keep_points_on (BaseGeometry], optional) – point of the geometry to that intersect with these geometries are not removed. Defaults to None.

Raises:

Exception – [description]

Returns:

the

simplified version of the input geometry/geometries.

Return type:

Union[BaseGeometry, NDArray[BaseGeometry], GeoSeries, None]

Examples

The simplify function has some advanced options to control the simplification behaviour.

Using the keep_points_on parameter, you can specify geometries/locations where points should be preserved during simplification. In the following plot you see the result if you exclude the points on the minimum bounding box of the polygon being removed.

(Source code, png, hires.png, pdf)

../_images/simplify_keep_points_on.png