ST_DIMENSION()

All functions > GEOSPATIAL > ST_DIMENSION()

Returns the topological dimension of a geometry or geography.

Signatures

Dimension

Returns: Dimension: 0 for points, 1 for lines, 2 for polygons

ST_DIMENSION(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:

  • Point/MultiPoint returns 0
  • LineString/MultiLineString returns 1
  • Polygon/MultiPolygon returns 2
  • GeometryCollection returns the maximum dimension of its children
  • Returns NULL if the input is NULL

Examples

FeatureQL
SELECT
    f1 := ST_DIMENSION(ST_GEOMPOINT(1.0, 2.0)), -- Point is dimension 0
    f2 := ST_DIMENSION(ST_GEOMFROMTEXT('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))')) -- Polygon is dimension 2
;
Result
f1 BIGINTf2 BIGINT
02

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