This topic describes the ST_NumGeometries function. If the input geometry object is a collection of geometries, such as a GeometryCollection or MULTI object, this function returns the number of geometry objects of the input geometry object. If the input geometry object is a single geometry object, this function returns 1. In other cases, this function returns NULL.
Syntax
integer ST_NumGeometries(geometry geom);
Parameters
Parameter | Description |
---|---|
geom | The geometry object that you want to specify. |
Description
This function supports polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.
Examples
- Results returned by specifying a MULTI object:
SELECT ST_NumGeometries('MULTIPOLYGON(((1 0,0 3,3 0,1 0)),((1 0,2 0,0 2,1 0)))'::geometry); st_numgeometries ------------------ 2 (1 row)
- Results returned by specifying a GeometryCollection object:
SELECT ST_NumGeometries('GeometryCollection(POINT(1 0),POLYGON((1 0,2 0, 0 2,1 0)))'::geometry); st_numgeometries ------------------ 2 (1 row)