This topic describes the ST_AddPoint function. This function adds a point to a LineString object.


geometry  ST_AddPoint(geometry  linestring , geometry  point);
geometry  ST_AddPoint(geometry  linestring , geometry  point , integer  position);


Parameter Description
linestring The geometry object that you want to specify.
point The point that you want to add.
position The position to which you want to add the point.


  • The position indexes start from 0.
  • If the value of the position parameter is -1, the point is added to the end of the LineString object.
  • This function supports 3D objects and does not delete z coordinates.


SELECT ST_AsEWKT(ST_AddPoint(ST_GeomFromEWKT('LINESTRING(0 0,0 1)'), ST_MakePoint(1,2)));
 LINESTRING(0 0,0 1,1 2)
(1 row)