Returns the inherent dimension of a geometry object.
Syntax
integer ST_Dimension(geometry g);Parameters
| Parameter | Description |
|---|---|
g | The geometry object. |
Return values
Returns an integer representing the inherent dimension of the input geometry.
| Returned value | Geometry subtype |
|---|---|
0 | POINT |
1 | LINESTRING |
2 | POLYGON |
0 | Empty GEOMETRYCOLLECTION (unknown dimension) |
| Largest dimension of the components | Non-empty GEOMETRYCOLLECTION |
This function supports polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.
Examples
The following example queries the dimension of a POINT geometry.
SELECT ST_Dimension('POINT(1 0)');Result:
st_dimension
--------------
0
(1 row)The following example shows the behavior for a GEOMETRYCOLLECTION. ST_Dimension returns the largest dimension among its components — in this case 1 (from the LINESTRING), which is larger than 0 (from the POINT).
SELECT ST_Dimension('GEOMETRYCOLLECTION(LINESTRING(0 0,1 0),POINT(1 0))');Result:
st_dimension
--------------
1
(1 row)