Package pygeodesy :: Module simplify |
[frames] | no frames]

# Module simplify

Simplify or linearize a path.

Each of the simplify functions is based on a different algorithm and produces different, simplified results in (very) different run times for the same path of `LatLon` points.

Function simplify1 eliminates points based on edge lengths shorter than a given tolerance.

The functions simplifyRDP and simplifyRDPm use the original, respectively modified Ramer-Douglas-Peucker (RDP) algorithm, iteratively finding the point farthest from each path edge. The difference is that function simplifyRDP exhaustively searches the most distant point in each iteration, while modified simplifyRDPm stops at the first point exceeding the distance tolerance.

Function simplifyRW use the Reumann-Witkam method, sliding a "pipe" over each path edge, removing all subsequent points within, closer than the pipe radius up to the first point outside the pipe.

Functions simplifyVW and simplifyVWm are based on the original, respectively modified Visvalingam-Whyatt (VW) method using the area of the triangle formed by three neigboring points. Function simplifyVW removes only a single point per iteration, while modified simplifyVWm eliminates in each iteration all points with a triangular area not exceeding the tolerance.

Functions simplifyRDP, simplifyRDPm and simplifyRW provide keyword argument shortest to specify of the distance between a point and a path edge. If `True`, use the shortest distance to the path edge or edge points, otherwise use the perpendicular distance to the extended line through both path edge points.

Keyword argument `radius` of all fuctions is set to the mean earth radius in `meter`. Other units can be used, provided that the radius and tolerance are always specified in the same units.

Use keyword argument `indices=True` in any function to return a list of simplified point indices instead of the simplified points. The first and last index are always the first and last original index.

Finally, any additional keyword arguments `options` to all functions are passed thru to function pygeodesy.equirectangular4 to specify the distance approximation.

To process `NumPy` arrays containing rows of lat-, longitude and possibly other values, use class Numpy2LatLon to wrap the `NumPy` array into on-the-fly-LatLon points. Pass the Numpy2LatLon instance to any simplify function and the returned result will be a `NumPy` array containing the simplified subset, a partial copy of the original `NumPy` array. Use keyword argument `indices=True` to return a list of array row indices inlieu of the simplified array subset.

See:

- https://Bost.Ocks.org/mike/simplify
- https://WikiPedia.org/wiki/Ramer-Douglas-Peucker_algorithm
- https://www.ScienceDirect.com/science/article/pii/S0098300402000092
- https://hydra.Hull.ac.UK/resources/hull:8338
- https://psimpl.SourceForge.net/reumann-witkam.html
- https://www.CS.UBC.Ca/cgi-bin/tr/1992/TR-92-07.pdf
- https://GitHub.com/FlorianWilhelm/gps_data_with_python
- https://www.BDCC.co.UK/Gmaps/GDouglasPeuker.js
- https://GitHub.com/mourner/simplify-js
- https://GitHub.com/OmarEstrella/simplify.py
- https://PyPI.org/project/rdp
- https://PyPI.org/project/visvalingam
- https://PyPI.org/project/simplification

Version: 24.08.13

Functions
simplify1(points, distance=0.001, radius=6371008.771415, indices=False, **options) Basic simplification of a path of `LatLon` points. |
simplifyRDP(points, distance=0.001, radius=6371008.771415, shortest=False, indices=False, **options) Ramer-Douglas-Peucker (RDP) simplification of a path of `LatLon` points. |
simplifyRDPm(points, distance=0.001, radius=6371008.771415, shortest=False, indices=False, **options) Modified Ramer-Douglas-Peucker (RDPm) simplification of a path of `LatLon` points. |
simplifyRW(points, pipe=0.001, radius=6371008.771415, shortest=False, indices=False, **options) Reumann-Witkam (RW) simplification of a path of `LatLon` points. |
simplifyVW(points, area=0.001, radius=6371008.771415, attr=None, indices=False, **options) Visvalingam-Whyatt (VW) simplification of a path of `LatLon` points. |
simplifyVWm(points, area=0.001, radius=6371008.771415, attr=None, indices=False, **options) Modified Visvalingam-Whyatt (VWm) simplification of a path of `LatLon` points. |

Variables
| __all__ = `_ALL_LAZY.simplify`

Function Details

### simplify1 (points, distance=0.001, radius=6371008.771415, indices=False, **options) |
Basic simplification of a path of `LatLon` points. Eliminates any points closer together than the given distance tolerance. Arguments: `points` - Path points (`LatLon`[]). `distance` - Tolerance (`meter`, same units as `radius`). `radius` - Mean earth radius (`meter`). `indices` - If `True`, return the simplified point indices instead of the simplified points (`bool`). `options` - Optional keyword arguments passed thru to function pygeodesy.equirectangular4. Returns: Simplified points (`LatLon`[]). Raises: `LimitError` - Lat- and/or longitudinal delta exceeds the `limit`, see function pygeodesy.equirectangular4. `ValueError` - Tolerance `distance` or `radius` too small.

### simplifyRDP (points, distance=0.001, radius=6371008.771415, shortest=False, indices=False, **options) |
Ramer-Douglas-Peucker (RDP) simplification of a path of `LatLon` points. Eliminates any points too close together or closer to an edge than the given distance tolerance. This `RDP` method exhaustively searches for the point with the largest distance, resulting in worst-case complexity O(n**2) where n is the number of points. Arguments: `points` - Path points (`LatLon`[]). `distance` - Tolerance (`meter`, same units as `radius`). `radius` - Mean earth radius (`meter`). `shortest` - If `True`, use the shortest otherwise the perpendicular distance (`bool`). `indices` - If `True`, return the simplified point indices instead of the simplified points (`bool`). `options` - Optional keyword arguments passed thru to function pygeodesy.equirectangular4. Returns: Simplified points (`LatLon`[]). Raises: `LimitError` - Lat- and/or longitudinal delta exceeds the `limit`, see function pygeodesy.equirectangular4. `ValueError` - Tolerance `distance` or `radius` too small.

### simplifyRDPm (points, distance=0.001, radius=6371008.771415, shortest=False, indices=False, **options) |
Modified Ramer-Douglas-Peucker (RDPm) simplification of a path of `LatLon` points. Eliminates any points too close together or closer to an edge than the given distance tolerance. This `RDPm` method stops at the first point farther than the given distance tolerance, significantly reducing the run time (but producing results different from the original `RDP` method). Arguments: `points` - Path points (`LatLon`[]). `distance` - Tolerance (`meter`, same units as `radius`). `radius` - Mean earth radius (`meter`). `shortest` - If `True`, use the shortest otherwise the perpendicular distance (`bool`). `indices` - If `True`, return the simplified point indices instead of the simplified points (`bool`). `options` - Optional keyword arguments passed thru to function pygeodesy.equirectangular4. Returns: Simplified points (`LatLon`[]). Raises: `LimitError` - Lat- and/or longitudinal delta exceeds the `limit`, see function pygeodesy.equirectangular4. `ValueError` - Tolerance `distance` or `radius` too small.

### simplifyRW (points, pipe=0.001, radius=6371008.771415, shortest=False, indices=False, **options) |
Reumann-Witkam (RW) simplification of a path of `LatLon` points. Eliminates any points too close together or within the given pipe tolerance along an edge. Arguments: `points` - Path points (`LatLon`[]). `pipe` - Pipe radius, half-width (`meter`, same units as `radius`). `radius` - Mean earth radius (`meter`). `shortest` - If `True`, use the shortest otherwise the perpendicular distance (`bool`). `indices` - If `True`, return the simplified point indices instead of the simplified points (`bool`). `options` - Optional keyword arguments passed thru to function pygeodesy.equirectangular4. Returns: Simplified points (`LatLon`[]). Raises: `LimitError` - Lat- and/or longitudinal delta exceeds the `limit`, see function pygeodesy.equirectangular4. `ValueError` - Tolerance `pipe` or `radius` too small.

### simplifyVW (points, area=0.001, radius=6371008.771415, attr=None, indices=False, **options) |
Visvalingam-Whyatt (VW) simplification of a path of `LatLon` points. Eliminates any points too close together or with a triangular area not exceeding the given area tolerance squared. This `VW` method exhaustively searches for the single point with the smallest triangular area, resulting in worst-case complexity O(n**2) where n is the number of points. Arguments: `points` - Path points (`LatLon`[]). `area` - Tolerance (`meter`, same units as `radius`). `radius` - Mean earth radius (`meter`). `attr` - Optional, points attribute to save the area value (`str`). `indices` - If `True`, return the simplified point indices instead of the simplified points (`bool`). `options` - Optional keyword arguments passed thru to function pygeodesy.equirectangular4. Returns: Simplified points (`LatLon`[]). Raises: `AttributeError` - If an `attr` is specified for Numpy2 `points`. `LimitError` - Lat- and/or longitudinal delta exceeds the `limit`, see function pygeodesy.equirectangular4. `ValueError` - Tolerance `area` or `radius` too small.

### simplifyVWm (points, area=0.001, radius=6371008.771415, attr=None, indices=False, **options) |
Modified Visvalingam-Whyatt (VWm) simplification of a path of `LatLon` points. Eliminates any points too close together or with a triangular area not exceeding the given area tolerance squared. This `VWm` method removes all points with a triangular area below the tolerance in each iteration, significantly reducing the run time (but producing results different from the original `VW` method). Arguments: `points` - Path points (`LatLon`[]). `area` - Tolerance (`meter`, same units as `radius`). `radius` - Mean earth radius (`meter`). `attr` - Optional, points attribute to save the area value (`str`). `indices` - If `True`, return the simplified point indices instead of the simplified points (`bool`). `options` - Optional keyword arguments passed thru to function pygeodesy.equirectangular4. Returns: Simplified points (`LatLon`[]). Raises: `AttributeError` - If an `attr` is specified for Numpy2 `points`. `LimitError` - Lat- and/or longitudinal delta exceeds the `limit`, see function pygeodesy.equirectangular4. `ValueError` - Tolerance `area` or `radius` too small.