This topic describes the ST_Dimension function. This function returns the inherent dimension of a geometry object.

Syntax

integer  ST_Dimension(geometry  g);

Parameters

Parameter Description
g The geometry object that you want to specify.

Description

  • This function returns different inherent dimensions when you specify different types of geometry objects.
    • If you specify a point object, this function returns 0.
    • If you specify a LineString object, this function returns 1.
    • If you specify a polygon object, this function returns 2.
  • If you specify a GeometryCollection object, this function returns the largest dimension of components of the object.
  • If you specify an object whose inherent dimension is unknown, such as an empty GeometryCollection object, this function returns 0.
  • This function supports polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.

Examples

  • SELECT ST_Dimension('POINT(1 0)');
     st_dimension
    --------------
                0
    (1 row)
                        
  • Results returned by specifying a GeometryCollection object:
    SELECT ST_Dimension('GEOMETRYCOLLECTION(LINESTRING(0 0,1 0),POINT(1 0))');
     st_dimension
    --------------
                1
    (1 row)