All Products
Search
Document Center

PolarDB:ST_Dimension

Last Updated:Mar 28, 2026

Returns the inherent dimension of a geometry object.

Syntax

integer ST_Dimension(geometry g);

Parameters

ParameterDescription
gThe geometry object.

Return values

Returns an integer representing the inherent dimension of the input geometry.

Returned valueGeometry subtype
0POINT
1LINESTRING
2POLYGON
0Empty GEOMETRYCOLLECTION (unknown dimension)
Largest dimension of the componentsNon-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)