ST_Dimension
Determine the dimension of a geometry, or the highest dimension of the contents of a geometry collection.
Note that the dimension of a geometry is not the same thing as the number of coordinate dimensions. For example, a point geometry that is defined with x and y coordinates has 2 coordinate dimensions but a geometry dimension of 0.
Syntax
ST_Dimension(geo);
- geo
- The input geometry.
Type: VARCHAR(ANY)
Returns
A value of type INT that indicates the dimension of a geometry or, for a geometry collection, the
dimension of the geometry in that collection that has the highest dimension:
- 0
- The geometry is a point.
- 1
- The geometry is a line.
- 2
- The geometry is a polygon.
- -1
- The geometry collection is empty.
Examples
SELECT inza..ST_Dimension(inza..ST_WKTToSQL('POINT (0 0)'));
ST_DIMENSION
------------
0
(1 row)
SELECT inza..ST_Dimension(inza..ST_WKTToSQL('LINESTRING (0 0, 1 1)'));
ST_DIMENSION
------------
1
(1 row)
SELECT inza..ST_Dimension(inza..ST_WKTToSQL('POLYGON ((1 1, 1 2, 2 2, 2 1, 1 1))'));
ST_DIMENSION
------------
2
(1 row)