PostGISGeometry Editors

ST_RemovePoint

What is ST_RemovePoint?

ST_RemovePoint deletes the vertex at a given zero-based index from a LineString, returning a new LineString with one fewer vertex.

SQL
ST_RemovePoint(geometry linestring, integer offset)geometry

The input must be a LineString. The offset is zero-based and must be less than the number of existing points.

When would you use ST_RemovePoint?

Use ST_RemovePoint to drop a specific bad vertex — for instance a GPS outlier spike, a misplaced digitising click, or a redundant doubled vertex. In editing pipelines it is used alongside ST_AddPoint and ST_SetPoint to patch individual coordinates without re-digitising the whole line.

For bulk cleaning, prefer ST_RemoveRepeatedPoints, which removes all duplicate consecutive vertices in one pass.

FAQs

Can I use ST_RemovePoint on a Polygon?

No. Only LineStrings are accepted. To remove a vertex from a polygon, extract the ring with ST_ExteriorRing, modify, and rebuild with ST_MakePolygon.

What happens if offset is out of range?

PostGIS raises an "Invalid offset" error. Validate index bounds before calling.

Will a two-point LineString survive a removal?

No — after removal a LineString needs at least two points. The call fails on two-point lines.

How do I remove multiple points at once?

Iterate with successive calls, or use ST_DumpPoints and ST_MakeLine to rebuild from filtered vertex lists. For duplicates, ST_RemoveRepeatedPoints is more efficient.