ST_PointN¶
Returns the Nth point in a linestring.
Usage¶
geometry ST_PointN(geom: geometry, n: integer)
geography ST_PointN(geog: geography, n: integer)
Arguments¶
- geog (geography): Input geography
- n (integer)
- geom (geometry): Input geometry
Description¶
Return the Nth point in a single linestring. Negative values are counted backwards from the end of the LineString such that -1 is the last point. Returns NULL if there is no linestring in the geometry.
Examples¶
SELECT ST_PointN(ST_GeomFromText('LINESTRING (0 0, 1 2, 2 4)'), 2);
┌─────────────────────────────────────────────────────────────────────────┐
│ st_pointn(st_geomfromtext(Utf8("LINESTRING (0 0, 1 2, 2 4)")),Int64(2)) │
│ geometry │
╞═════════════════════════════════════════════════════════════════════════╡
│ POINT(1 2) │
└─────────────────────────────────────────────────────────────────────────┘
SELECT ST_PointN(ST_GeogFromWKT('LINESTRING (0 0, 1 2, 2 4)'), 2);
┌────────────────────────────────────────────────────────────────────────┐
│ st_pointn(st_geogfromwkt(Utf8("LINESTRING (0 0, 1 2, 2 4)")),Int64(2)) │
│ geography │
╞════════════════════════════════════════════════════════════════════════╡
│ POINT(1 2) │
└────────────────────────────────────────────────────────────────────────┘