This topic describes the ST_AddPoint function. This function adds a point to a LineString object.
Syntax
geometry ST_AddPoint(geometry linestring , geometry point);
geometry ST_AddPoint(geometry linestring , geometry point , integer position);
Parameters
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. |
Description
- 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.
Examples
SELECT ST_AsEWKT(ST_AddPoint(ST_GeomFromEWKT('LINESTRING(0 0,0 1)'), ST_MakePoint(1,2)));
st_asewkt
-------------------------
LINESTRING(0 0,0 1,1 2)
(1 row)