ST_GEOMPOINTN()

All functions > GEOSPATIAL > ST_GEOMPOINTN()

Returns the Nth vertex of a LineString (1-indexed).

Signatures

Point N

Returns: The Nth vertex

ST_GEOMPOINTN(line: T, n: INT) → GEOM_POINT or GEOG_POINT
sql
ParameterTypeRequiredDescription
lineTYesA LineString geometry or geography
nINTYes1-based vertex index

With:

  • T : Custom types: GEOM_LINESTRING | GEOG_LINESTRING

Signature notes:

  • Index is 1-based; ST_GEOMPOINTN(line, 1) returns the same point as ST_STARTPOINT(line)
  • Out of range index returns NULL
  • Input must be a LineString; other sub kinds return NULL
  • Returns NULL if any input is NULL

Examples

FeatureQL
SELECT
    f1 := ST_ASTEXT(ST_GEOMPOINTN(ST_GEOMFROMTEXT('LINESTRING (0 0, 1 1, 2 0)'), 2)) -- Second vertex of a 3-vertex line
;
Result
f1 VARCHAR
POINT (1 1)

Last update at: 2026/05/26 17:22:09