ST_Dimension takes a geometry column and returns an integer column. The output column represents the dimensionality of the input geometry. Points and multipoints have a dimension of 0, lines 1, and polygons 2.
Function | Syntax |
---|---|
Python | dimension(geometry) |
SQL | ST |
Scala | dimension(geometry) |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for dimension.
This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.
Examples
from geoanalytics_fabric.sql import functions as ST, Linestring, MultiPoint, Point, Polygon
data = [
("point", "POINT (10 30)"),
("multipoint", "MULTIPOINT (0 0, 5 5, 0 5)"),
("linestring", "LINESTRING (15 15, 10 15, 12 2)"),
("polygon", "POLYGON ((20 30, 18 28, 22 35, 40 20))")
]
df = spark.createDataFrame(data, ["type", "wkt"])\
.withColumn("geometry", ST.geom_from_text("wkt"))
df.select("type", ST.dimension("geometry").alias("dimension")).show()
Result
+----------+---------+
| type|dimension|
+----------+---------+
| point| 0|
|multipoint| 0|
|linestring| 1|
| polygon| 2|
+----------+---------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |