ST_RemovePoint

更新时间:
复制 MD 格式

Removes a point at the specified index from a LineString geometry.

Syntax

geometry ST_RemovePoint(geometry linestring, integer offset);

Parameters

ParameterDescription
linestringThe LineString geometry to modify.
offsetThe zero-based index of the point to remove.

Usage notes

  • The index is zero-based: the first point has index 0.

  • Use this function to convert a closed ring into an open LineString by removing the duplicate end point.

  • Supports 3D geometries and preserves Z coordinates.

Examples

Remove the first point from a LineString

SELECT ST_AsText(ST_RemovePoint(ST_GeomFromText('LINESTRING(2 1,1 1,1 0)'), 0));

Output:

      st_astext
---------------------
 LINESTRING(1 1,1 0)
(1 row)