Zum Hauptinhalt springen

raygeo.geo.algo.simplify

Polyline simplification using the Ramer-Douglas-Peucker algorithm.

Reduces the number of points in a polyline while preserving the overall shape within a given tolerance.

Functions

simplify_polyline()

simplify_polyline(
points: Sequence[types.Point],
tolerance: float,
) -> types.Polygon

Simplify a 2D polyline using the Ramer-Douglas-Peucker algorithm.

Reduces the number of points while preserving shape within tolerance.

ParameterTypeDescription
pointsSequence[types.Point]Sequence of (x, y) points.
tolerancefloatSimplification tolerance.
Returnstypes.PolygonSimplified 2D point sequence.
ComplexityO(n log n) average time, O(n) space

simplify_polyline_3d()

simplify_polyline_3d(
points: Sequence[types.Point3D],
tolerance: float,
) -> types.Polygon3D

Simplify a 3D polyline using the Ramer-Douglas-Peucker algorithm.

The simplification uses XY distance, but preserves Z coordinates of kept points.

ParameterTypeDescription
pointsSequence[types.Point3D]Sequence of (x, y, z) points.
tolerancefloatSimplification tolerance.
Returnstypes.Polygon3DSimplified 3D point sequence.
ComplexityO(n log n) average time, O(n) space

Simplify and linearize

Simplify and linearize

3D polyline simplification preserving Z coordinates

3D polyline simplification preserving Z coordinates