📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

ST_DIMENSION



Return the dimension for a geometry object. The dimension of a GEOMETRY or GEOGRAPHY object is:

Geospatial Object TypeDimension
Point / MultiPoint0
LineString / MultiLineString1
Polygon / MultiPolygon2

Syntax

ST_DIMENSION(<geometry_or_geography>)

Arguments

ArgumentsDescription
<geometry_or_geography>The argument must be an expression of type GEOMETRY or GEOGRAPHY.

Return Type

UInt8.

Examples

GEOMETRY examples

SELECT ST_DIMENSION( ST_GEOMETRYFROMWKT( 'POINT(-122.306100 37.554162)' ) ) AS pipeline_dimension; ┌────────────────────┐ │ pipeline_dimension │ ├────────────────────┤ │ 0 │ └────────────────────┘ SELECT ST_DIMENSION( ST_GEOMETRYFROMWKT( 'LINESTRING(-124.20 42.00, -120.01 41.99)' ) ) AS pipeline_dimension; ┌────────────────────┐ │ pipeline_dimension │ ├────────────────────┤ │ 1 │ └────────────────────┘ SELECT ST_DIMENSION( ST_GEOMETRYFROMWKT( 'POLYGON((-124.20 42.00, -120.01 41.99, -121.1 42.01, -124.20 42.00))' ) ) AS pipeline_dimension; ┌────────────────────┐ │ pipeline_dimension │ ├────────────────────┤ │ 2 │ └────────────────────┘

GEOGRAPHY examples

SELECT ST_DIMENSION( ST_GEOGFROMWKT( 'LINESTRING(-124.20 42.00, -120.01 41.99)' ) ) AS pipeline_dimension; ╭────────────────────╮ │ pipeline_dimension │ ├────────────────────┤ │ 1 │ ╰────────────────────╯

Was this page helpful?