shapely.remove_repeated_points#

remove_repeated_points(geometry, tolerance=0.0, **kwargs)#

Returns a copy of a Geometry with repeated points removed.

Note

‘remove_repeated_points’ requires at least GEOS 3.11.0.

From the start of the coordinate sequence, each next point within the tolerance is removed.

Removing repeated points with a non-zero tolerance may result in an invalid geometry being returned.

Parameters
geometryGeometry or array_like
tolerancefloat or array_like, default=0.0

Use 0.0 to remove only exactly repeated points.

Examples

>>> from shapely import LineString, Polygon
>>> remove_repeated_points(LineString([(0,0), (0,0), (1,0)]), tolerance=0)
<LINESTRING (0 0, 1 0)>
>>> remove_repeated_points(Polygon([(0, 0), (0, .5), (0, 1), (.5, 1), (0,0)]), tolerance=.5)
<POLYGON ((0 0, 0 1, 0 0, 0 0))>