Adds a point to a LineString geometry.
Syntax
geometry ST_AddPoint(geometry linestring, geometry point);
geometry ST_AddPoint(geometry linestring, geometry point, integer position);Parameters
| Parameter | Description |
|---|---|
linestring | The LineString geometry to modify. |
point | The point to add. |
position | The index at which to insert the point. Indexes start at 0. Set to -1 to append the point to the end of the LineString. |
Usage notes
Position indexes start at 0.
Set
positionto-1to append the point to the end of the LineString.Supports 3D geometries. Z coordinates are preserved.
Examples
Append a point to a two-point LineString:
SELECT ST_AsEWKT(ST_AddPoint(ST_GeomFromEWKT('LINESTRING(0 0,0 1)'), ST_MakePoint(1,2)));Output:
st_asewkt
-------------------------
LINESTRING(0 0,0 1,1 2)
(1 row)该文章对您有帮助吗?