Skip to main content
RETURN Linestring with additional point at the given index, if position is not available the point will be added at the end of line. ST_AddPoint

Signatures

ST_AddPoint(geom: Geometry, point: Geometry, position: Integer)
ST_AddPoint(geom: Geometry, point: Geometry)

Parameters

geom
Geometry
required
The input geometry.
point
Geometry
required
The point value.
position
Integer
The position value.

Return type

The resulting geometry.

Example

SELECT ST_AddPoint(ST_GeomFromText("LINESTRING(0 0, 1 1, 1 0)"), ST_GeomFromText("Point(21 52)"), 1)

SELECT ST_AddPoint(ST_GeomFromText("Linestring(0 0, 1 1, 1 0)"), ST_GeomFromText("Point(21 52)"))
LINESTRING(0 0, 21 52, 1 1, 1 0)
LINESTRING(0 0, 1 1, 1 0, 21 52)