This topic describes the ST_SetPoint function. This function replaces the points of a LineString object with the specified points. The coordinates of points are specified by indexes.

Syntax

geometry  ST_SetPoint(geometry  linestring , integer  zerobasedposition , geometry  point);

Parameters

Parameter Description
linestring The geometry object that you want to specify.
zerobasedposition The position of the replacement. The position indexes start from 0.
point The point that is used for replacement.

Description

  • Negative indexes are counted backward, and -1 is the last point.
  • The ST_SetPoint function is useful in triggers when you trying to maintain the relationship of joints when one vertex moves.
  • This function supports 3D objects and does not delete z coordinates.

Examples

SELECT ST_AsText(ST_SetPoint(ST_GeomFromText('LINESTRING(2 1,1 1)'),0,ST_MakePoint(0,1)));
      st_astext
---------------------
 LINESTRING(0 1,1 1)
(1 row)