ST_NUMGEOMETRIES()

All functions > GEOSPATIAL > ST_NUMGEOMETRIES()

Returns the number of sub geometries in a collection, or 1 for singular geometries.

Signatures

Number of geometries

Returns: Number of sub geometries

ST_NUMGEOMETRIES(geo: T) → BIGINT
sql
ParameterTypeRequiredDescription
geoTYesGeometry or geography value

With:

  • T : Custom types: GEOM_POINT | GEOM_LINESTRING | GEOM_POLYGON | GEOM_MULTIPOINT | GEOM_MULTILINESTRING | GEOM_MULTIPOLYGON | GEOM_MULTIANY | GEOG_POINT | GEOG_LINESTRING | GEOG_POLYGON | GEOG_MULTIPOINT | GEOG_MULTILINESTRING | GEOG_MULTIPOLYGON | GEOG_MULTIANY

Signature notes:

  • Multi*/GeometryCollection: returns the number of children
  • Singular geometry (Point, LineString, Polygon): returns 1
  • Empty geometry: returns 0
  • Returns NULL if the input is NULL

Examples

FeatureQL
SELECT
    f1 := ST_NUMGEOMETRIES(ST_GEOMFROMTEXT('MULTIPOINT ((0 0), (1 1), (2 2))')), -- MultiPoint with 3 children
    f2 := ST_NUMGEOMETRIES(ST_GEOMPOINT(1.0, 2.0)) -- Singular geometry returns 1
;
Result
f1 BIGINTf2 BIGINT
31

Last update at: 2026/05/26 17:22:09