ST_Dimension

更新时间:
复制 MD 格式

Returns the inherent dimension of a geometry object.

Syntax

integer ST_Dimension(geometry g);

Parameters

ParameterDescription
gThe geometry object.

Return values

The return value depends on the type of the input geometry object.

Input typeReturn value
Point0
LineString1
Polygon2
GeometryCollectionThe 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)