cartagen.simplify_lang#
- simplify_lang(geometry, tolerance, look_ahead=5)#
Simplify a line or polygon using a look-ahead distance-based selection.
This algorithm, proposed by Lang [1], performs a simplification by defining a search region of a fixed number of vertices (look-ahead). It serves as a middle ground between local sequential filters and global algorithms like Douglas-Peucker.
The principle of the algorithm is to create a segment between the current vertex and a vertex further down the line. The perpendicular distances from all intermediate vertices to this segment are calculated. If any distance exceeds the tolerance, the search region is shrunk by moving the end vertex one step closer to the start, and the process repeats until all intermediate points fall within the tolerance. Once a valid segment is found, all intermediate points are removed, and the process restarts from the end of that segment.
- Parameters:
geometry (
LineString,MultiLineString,Polygon,MultiPolygon,LinearRing) – The geometry to simplify.tolerance (
float) – The maximum allowed perpendicular distance between the original vertices and the simplified segment.look_ahead (
int, optional) – The maximum number of vertices to consider in a single search window. Higher values allow for more aggressive simplification but increase computational cost.
- Returns:
LineString,MultiLineString,Polygon,MultiPolygon,LinearRing
See also
simplify_angularSimplify a line or polygon by removing vertexes with small angles.
simplify_douglas_peuckerSimplify a line or polygon using a distance-based selection.
simplify_li_openshawSimplify a line or a polygon using a regular grid.
simplify_raposoSimplify a line or a polygon using an hexagonal tessellation.
simplify_reumann_witkamSimplify a line or polygon using a directional distance-based selection.
simplify_visvalingam_whyattSimplify a line or polygon using an area-based selection.
simplify_wang_mullerSimplify a line or polygon using a bend-reduction method.
simplify_whirlpoolSimplify a line or polygon using an epsilon-circle based selection.
References
Examples
>>> line = LineString([(0, 0), (1, 0.1), (2, 0.2), (3, 5), (4, 0)]) >>> simplify_lang(line, tolerance=0.5, look_ahead=4) <LINESTRING (0 0, 2 0.2, 3 5, 4 0)>