ST_NumGeometries

Determine the number of geometries in a geometry collection.

Syntax

ST_NumGeometries(geo);
geo
The input geometry.

Type: VARCHAR(ANY)

Returns

A value of type INT4 that represents the number of geometries in the geometry. It returns 1 for a geometry that is not a collection.

Examples

SELECT inza..ST_NumGeometries(inza..ST_WKTToSQL('GEOMETRYCOLLECTION (POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10)), POINT (5 6))'));
 
ST_NUMGEOMETRIES
------------------
2
(1 row)
SELECT inza..ST_NumGeometries(inza..ST_POINT(1, 5)); 

ST_NUMGEOMETRIES
------------------
1
(1 row)