Name

ST_Dimension — Returns the dimension of the geometric object, which is less than or equal to the dimension of the coordinate space.

Synopsis

geometry ST_Dimension(bytea Geometry);

Alias

Dimension

Description

Returns the dimension of the geometric object, which is less than or equal to the dimension of the coordinate space.

Returns 0 for POINT, 1 for LINESTRING, 2 for POLYGON, and the largest dimension of the components of a GEOMETRYCOLLECTION.

Coordinate Dimensions
2D3DM
Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
2.1.1.17.2.10.1-5.1.2

Examples

SELECT ST_Dimension(ST_GeomFromText('POINT (0 0)'));
--Result
0

SELECT ST_Dimension(ST_GeomFromText('LINESTRING(0 0 2 -4,5 0 8 -4,10 0 6 -2)'));
--Result
1

SELECT Dimension(ST_GeomFromText('POLYGON ((20 20, 50 20, 50 50, 20 50, 20 20))'));
--Result
2

SELECT ST_Dimension(ST_GeomFromText('GEOMETRYCOLLECTION(POINT (5 5 10),LINESTRING (0 0 10, 0 50 10))'));
--Result
1

Related functions

ST_CoordDim