simplify#

geodesic.boson.simplify(threshold, stride=2, input_collection=None, output_collection=None)[source]#

Simplify the queried geometry.

This middleware will simplify the geometry by removing points according to the `Ramer-Douglas-Peucker Algorithm<https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm>`_. This is useful for reducing the size of the geometry for visualization or other purposes. The threshold is approximately the scale at which points will be removed. A smaller threshold will cause more points of the original geometry to be kept, and larger will cause more to be thrown away. The stride parameter controls how many points are checked against the threshold when simplifying. A larger stride will simplify the geometry faster but may result in a less accurate simplification. If you are not familiar with this algorithm, it is recommended that you leave stride at the default value of 2.

When creating this middleware, most of the time you will want to apply it after any filtering happens, so that the centroid is calculated on the filtered geometry.

Note

The units of the threshold are the same as the units of the spatial reference of the geometry. For instance, if the geometry is in EPSG:4326, the threshold will be in degrees.

Parameters:
  • threshold (float) – distance between points that will be removed

  • stride (int, optional) – number of points to skip when simplifying. Defaults to 2.

  • input_collection (str, optional) – name of the input collection to apply transform to. Defaults to None (all collections)

  • output_collection (str, optional) – name of the virtual collection that the transform will be applied to. Defaults to None (no virtual collection created)

Returns:

middleware to simplify the queried geometry

Return type:

Middleware

Examples

>>> # Add the simplify middleware to a dataset view
>>> simplified_ds = ds.view(
...     middleware=[
...         simplify(threshold=0.01, stride=3)
...     ]
... )