Skip to main content

st_dimension function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 17.1 and above

Preview

This feature is in Public Preview.

Returns the topological dimension of the 2D projection of the GEOMETRY.

Syntax

st_dimension ( geoExpr )

Arguments

  • geoExpr: A GEOMETRY value.

Returns

Returns the topological dimension of the 2D projection of the input GEOMETRY. The expression returns:

  • 0, if the input GEOMETRY is a point or a multipoint.
  • 1, if the input GEOMETRY is a linestring or a multilinestring.
  • 2, if the input GEOMETRY is a polygon or a multipolygon.
  • 0, if the input is an empty GEOMETRY collection.
  • The maximum dimension of elements of the collection, if the input is a non-empty geometry collection.

Examples

SQL
> SELECT st_dimension(st_geomfromtext('MULTIPOINT(EMPTY,-1 0,EMPTY)'));
0

> SELECT st_dimension(st_geomfromtext('LINESTRING(-1 0,0 -1,1 0,0 1,-1 0)'));
1

> SELECT st_dimension(st_geomfromtext('MULTIPOLYGON(EMPTY,((-1 0,0 -1,1 0,0 1,-1 0)))'));
2

> SELECT st_dimension(st_geomfromtext('GEOMETRYCOLLECTION EMPTY'));
0