ST_GeometryN¶
Returns the 1-based Nth geometry if the geometry is a GEOMETRYCOLLECTION, (MULTI)POINT, (MULTI)LINESTRING, MULTICURVE or (MULTI)POLYGON.
Usage¶
geometry ST_GeometryN(geom: geometry, n: integer)
geography ST_GeometryN(geog: geography, n: integer)
Arguments¶
- geog (geography): Input geography
- n (integer)
- geom (geometry): Input geometry
Description¶
Returns NULL if the index is out of range.
Examples¶
SELECT ST_GeometryN(
ST_GeomFromText('MULTIPOINT ((1 2), (3 4), (5 6))'),
1
);
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_geometryn(st_geomfromtext(Utf8("MULTIPOINT ((1 2), (3 4), (5 6))")),Int64 │
│ (1))… │
╞══════════════════════════════════════════════════════════════════════════════╡
│ POINT(1 2) │
└──────────────────────────────────────────────────────────────────────────────┘
SELECT ST_GeometryN(
ST_GeogFromWKT('MULTIPOINT ((1 2), (3 4), (5 6))'),
1
);
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_geometryn(st_geogfromwkt(Utf8("MULTIPOINT ((1 2), (3 4), (5 6))")),Int64( │
│ 1))… │
╞══════════════════════════════════════════════════════════════════════════════╡
│ POINT(1 2) │
└──────────────────────────────────────────────────────────────────────────────┘