Skip to main content
This function eliminates consecutive duplicate points within a geometry, preserving endpoints of LineStrings. It operates on (Multi)LineStrings, (Multi)Polygons, and MultiPoints, processing GeometryCollection elements individually. When an optional ‘tolerance’ value is provided, vertices within that distance are also considered duplicates. ST_RemoveRepeatedPoints

Signatures

ST_RemoveRepeatedPoints(geom: Geometry, tolerance: Double)
ST_RemoveRepeatedPoints(geom: Geometry)

Parameters

geom
Geometry
required
The input geometry.
tolerance
Double
The distance tolerance.

Return type

The resulting geometry.

Examples

SELECT ST_RemoveRepeatedPoints(
        ST_GeomFromWKT('MULTIPOINT ((20 20), (10 10), (30 30), (40 40), (20 20), (30 30), (40 40))')
       )
MULTIPOINT ((20 20), (10 10), (30 30), (40 40))
SELECT ST_RemoveRepeatedPoints(
        ST_GeomFromWKT('LINESTRING (20 20, 10 10, 30 30, 40 40, 20 20, 30 30, 40 40)')
       )
LINESTRING (20 20, 10 10, 30 30, 40 40, 20 20, 30 30, 40 40)

Each geometry within a collection is processed independently.

ST_RemoveRepeatedPoints(
        ST_GeomFromWKT('GEOMETRYCOLLECTION (POINT (10 10), POINT(10 10), LINESTRING (20 20, 20 20, 30 30, 30 30), MULTIPOINT ((80 80), (90 90), (90 90), (100 100)))')
    )
GEOMETRYCOLLECTION (POINT (10 10), POINT (10 10), LINESTRING (20 20, 30 30), MULTIPOINT ((80 80), (90 90), (100 100)))

Elimination of repeated points within a specified distance tolerance.

SELECT ST_RemoveRepeatedPoints(
        ST_GeomFromWKT('LINESTRING (20 20, 10 10, 30 30, 40 40, 20 20, 30 30, 40 40)'),
        20
       )
LINESTRING (20 20, 40 40, 20 20, 40 40)