ST_NumGeometries
Returns the number of geometries contained within a spatial object.
	Returns the number of geometries contained within a spatial object. Single GEOMETRY or GEOGRAPHY objects return 1 and empty objects return NULL.
Behavior type
ImmutableSyntax
ST_NumGeometries( g )
Arguments
- g
- Spatial object of type GEOMETRY or GEOGRAPHY 
Returns
INTEGER
Supported data types
| Data Type | GEOMETRY | GEOGRAPHY (Perfect Sphere) | GEOGRAPHY (WGS84) | 
|---|---|---|---|
| Point | Yes | Yes | Yes | 
| Multipoint | Yes | Yes | Yes | 
| Linestring | Yes | Yes | Yes | 
| Multilinestring | Yes | Yes | Yes | 
| Polygon | Yes | Yes | Yes | 
| Multipolygon | Yes | Yes | Yes | 
| GeometryCollection | No | No | No | 
Examples
The following example shows how to use ST_NumGeometries.
Return the number of geometries:
=> SELECT ST_NumGeometries(ST_GeomFromText('MULTILINESTRING ((1 5, 2 4, 5 3, 6 6), (3 5, 3 7))'));
 ST_NumGeometries
------------------
                2
(1 row)