- Categories:
ST_DIMENSION¶
Given a value of type GEOGRAPHY or GEOMETRY, return the “dimension” of the value. The dimension of a GEOGRAPHY or GEOMETRY value is:
Geospatial Object Type |
Dimension |
|---|---|
Point / MultiPoint |
0 |
LineString / MultiLineString |
1 |
Polygon / MultiPolygon |
2 |
GeometryCollection |
The dimension of the collection is equal to the maximum dimension of all the values inside the collection. For example, if a GeometryCollection contains a Point (dimension 0) and a LineString (dimension 1), the dimension of the GeometryCollection is 1. |
Feature |
The dimension of the Feature is the same as the dimension of the geospatial object in the Feature. |
FeatureCollection |
The rule is the same as for GeometryCollection. |
The returned values (0, 1, 2) correspond to the common meaning of the word “dimension”: a polygon is a two-dimensional object, a line is a one-dimensional object, and a point is a zero-dimensional object.
Syntax¶
Arguments¶
geography_or_geometry_expressionThe argument must be an expression of type GEOGRAPHY or GEOMETRY.
Returns¶
A value of type INTEGER.
Usage notes¶
If the function is passed NULL, the function returns NULL.
For GEOGRAPHY objects:
If the function is passed a GeometryCollection containing at least one NULL element and no non-NULL elements, the function returns 0.
If the function is passed a GeometryCollection containing at least one NULL element and at least one non-NULL element, the function returns the maximum dimension of the non-NULL elements.
Note that some other systems return different values for NULL inputs.
Examples¶
GEOGRAPHY examples¶
The following example demonstrates the ST_DIMENSION function:
GEOMETRY examples¶
The following example demonstrates the ST_DIMENSION function: