ST_Dimension
ST_Dimension returns the inherent dimension of an input geometry. The inherent dimension is the dimension value of the subtype that is defined in the geometry.
For 3DM, 3DZ, and 4D geometry inputs, ST_Dimension returns the same result as for 2D geometry inputs.
Syntax
ST_Dimension(geom)
Arguments
- geom
-
A value of data type
GEOMETRY
or an expression that evaluates to aGEOMETRY
type.
Return type
INTEGER
representing the inherent dimension of geom.
If geom is null, then null is returned.
The values returned are as follows.
Returned value | Geometry subtype |
---|---|
0 |
Returned if geom is a |
1 |
Returned if geom is a |
2 |
Returned if geom is a |
0 |
Returned if geom is an empty |
Largest dimension of the components of the collection |
Returned if geom is a |
Examples
The following SQL converts a well-known text (WKT) representation of a four-point LINESTRING to a GEOMETRY object and returns the dimension of the linestring.
SELECT ST_Dimension(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'));
st_dimension
-------------
1