ST_Dimension — Returns the dimension of the geometric object, which is less than or equal to the dimension of the coordinate space.
geometry ST_Dimension(bytea
Geometry);
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.
| 2D | 3D | M |
|---|---|---|
![]() | ![]() | ![]() |
| 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.1 | 7.2.10.1 | - | 5.1.2 |
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