Skip to content

Returns a Point at a specified index in a LineString.

ST_POINTN(<geometry>, <index>)
ArgumentsDescription
<geometry>The argument must be an expression of type GEOMETRY that represents a LineString.
<index>The index of the Point to return.

Geometry.

SELECT
ST_POINTN(
ST_GEOMETRYFROMWKT(
'LINESTRING(1 1, 2 2, 3 3, 4 4)'
),
1
) AS pipeline_pointn;
┌─────────────────┐
│ pipeline_pointn │
├─────────────────┤
POINT(1 1) │
└─────────────────┘
SELECT
ST_POINTN(
ST_GEOMETRYFROMWKT(
'LINESTRING(1 1, 2 2, 3 3, 4 4)'
),
-2
) AS pipeline_pointn;
┌─────────────────┐
│ pipeline_pointn │
├─────────────────┤
POINT(3 3) │
└─────────────────┘