PostGISGeometry Editors

ST_RemoveRepeatedPoints

What is ST_RemoveRepeatedPoints?

ST_RemoveRepeatedPoints returns a copy of the input geometry with runs of equal consecutive vertices collapsed. An optional tolerance collapses near-duplicates within the given distance.

SQL
ST_RemoveRepeatedPoints(geometry geom, float tolerance = 0.0)geometry

Rings remain closed — the closing vertex is always preserved. The function is safe on Points, Lines, and Polygons.

When would you use ST_RemoveRepeatedPoints?

Use ST_RemoveRepeatedPoints to clean data imported from digitising software where double-clicks produced duplicated vertices, or tracks where a GPS device paused and repeated the last fix. It is also a quick way to pre-simplify geometry before computationally heavy operations like ST_Buffer or ST_Intersection.

For a topology-preserving reduction use ST_SimplifyPreserveTopology; for aggressive thinning use ST_Simplify.

FAQs

Does it remove non-consecutive duplicates?

No — only consecutive runs are collapsed. A line that loops back to a previous vertex still contains the loop.

Can I set a tolerance?

Yes. The second argument is a distance (in CRS units) under which neighbours are treated as duplicates. The default 0.0 matches only exact duplicates.

Will it break ring closure on polygons?

No. Ring closing points are preserved explicitly so the polygon remains valid.

How is it different from ST_Simplify?

ST_Simplify uses the Douglas-Peucker algorithm to drop vertices deemed redundant within a tolerance — it can remove non-consecutive vertices on straight runs. ST_RemoveRepeatedPoints only drops consecutive duplicates.