Returns the inherent dimension of a geometry object.
Syntax
integer ST_Dimension(geometry g);Parameters
| Parameter | Description |
|---|---|
g | The geometry object. |
Return values
The return value depends on the type of the input geometry object.
| Input type | Return value |
|---|---|
| Point | 0 |
| LineString | 1 |
| Polygon | 2 |
| GeometryCollection | The largest dimension among all components in the collection. |
| Empty GeometryCollection (or any geometry with unknown dimension) | 0 |
ST_Dimension also supports polyhedral surfaces, triangles, Triangulated Irregular Network (TIN) surfaces, and 3D objects.
Examples
Point
SELECT ST_Dimension('POINT(1 0)');
st_dimension
--------------
0
(1 row)GeometryCollection containing a LineString and a Point
The function returns 1 because LineString has the largest dimension among the components.
SELECT ST_Dimension('GEOMETRYCOLLECTION(LINESTRING(0 0,1 0),POINT(1 0))');
st_dimension
--------------
1
(1 row)该文章对您有帮助吗?