Skip to main content
Return the 1-based Nth geometry if the geometry is a GEOMETRYCOLLECTION, (MULTI)POINT, (MULTI)LINESTRING, MULTICURVE or (MULTI)POLYGON. Otherwise, return null ST_GeometryN
The index is 1-based: n = 1 returns the first geometry; zero, negative, or out-of-range indices return NULL. When migrating from a runtime with zero-based indices, add 1 to the old index. See Geometry and raster API migration.

Signatures

Parameters

Geometry
required
The input geometry.
Integer
required
The 1-based index of the geometry.

Return type

The resulting geometry.

Example