ST_GeometryN

Determine the Nth geometry from a geometry collection.

Syntax

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

Type: VARCHAR(ANY)

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

Type: INT

Returns

A value of type VARCHAR(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('GEO METRYCOLLECTION (POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10)), POINT (5 6))'), 2));

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