GeoRDPy Documentation¶
Introduction¶
Welcome to the documentation for GeoRDPy, a Python library for simplifying geodetic-coordinate polylines using the Ramer-Douglas-Peucker algorithm.
API Reference¶
geordpy module¶
- geordpy.rdp_filter(points, threshold, radius=6371000, rhumb_line_interpolation=False, n_samples=2048, n_iterations=3)¶
Simplify a geodetic-coordinate polyline using the Ramer-Douglas-Peucker algorithm.
This function applies the Ramer-Douglas-Peucker (RDP) algorithm to a list of geodetic-coordinate points, aiming to simplify the polyline while keeping the error below a specified threshold. The algorithm works by approximating the original polyline with a reduced number of points that lie close to the original curve. By default, the segments of the polyline are interpolated with a great-circle. Optionally, this can be changed to rhumb lines. For both options, the great-circle distance is used for finding the smallest distance between the interpolated segment and a given geodetic-coordinate point.
- Parameters:
points (list of tuple) – A list of latitude and longitude pairs (given in degrees) representing the geodetic-coordinate polyline points to be simplified.
threshold (float) – The maximum allowable error, specified as an arc length along great circle segments. Points that deviate from the simplified curve by more than this threshold will be kept.
radius (float, optional) – The radius of the sphere used for calculations. Defaults to Earth’s mean radius in meters (6371000). The threshold is interpreted based on this radius.
rhumb_line_interpolation (bool, optional) – Interpolate the segments of the polyline with rhumb lines instead of great-circle segments.
n_samples (int, optional) – Number of samples used to estimate the minimum distance between a rhumb line segment and a geodetic-coordinate.
n_iterations (int, optional) – Number of iterations used to estimate the minimum distance between a rhumb line segment and a geodetic-coordinate.
- Returns:
- A binary mask indicating whether each point in the input list should be kept or discarded
based on the RDP simplification. The mask has the same length as the input ‘points’ list, where a value of True indicates that the corresponding point should be kept, and False indicates that the point can be discarded.
- Return type:
Note
The input ‘points’ list should have at least two points to define a valid polyline.
The value of ‘threshold’ must be greater than zero.
The ‘radius’ value should be set appropriately to match the units of the threshold. For example, if the radius is set to 1, then the threshold corresponds to the arc length on the unit sphere.
The values of ‘n_samples’, and ‘n_iterations’ must be greater than zero if provided.
The values of ‘n_samples’ and ‘n_iterations’ have no effect on the precision of the result if great-circles are used for interpolating segments of the polyline.