ST_GeometryN

Determine the Nth geometry from a geometry collection.

Syntax

ST_GeometryN(geo, n);
geo
The input geometry collection.

Type: ST_GEOMETRY(ANY)

n
The index, starting with 1, that identifies the geometry in a collection.

Type: INT

Returns

A value of type ST_GEOMETRY(ANY) that contains a geometry, or NULL if the input geometry is not a geometry collection.

Examples

SELECT inza..ST_AsText(inza..ST_GeometryN(inza..ST_WKTToSQL('MULTIPOINT (10 10, 5 6)'), 2));

ST_ASTEXT
-----------
POINT (5 6)
(1 row)


SELECT inza..ST_AsText(inza..ST_GeometryN(inza..ST_WKTToSQL('MULTIPOINT (10 10, 5 6)'), 1));

ST_ASTEXT
-----------
POINT (10 10)
(1 row)