ST_NumGeometries

Determine the number of geometries in a geometry collection.

Syntax

ST_NumGeometries(geo);
geo
The input geometry.

Type: ST_GEOMETRY(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('MULTIPOLYGON (((10 10, 10 20, 20 20, 20 15, 10 10)), ((0 0, 1 0, 1 1, 0 1, 0 0)))'));
 
ST_NUMGEOMETRIES
------------------
2
(1 row)
SELECT inza..ST_NumGeometries(inza..ST_POINT(1, 5)); 

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