ST_Geometries

ST_Geometries takes a geometry column and returns an array column. Multipoint geometries return an array of points, multipart linestrings return an array of single-path linestrings, and multipart polygons return an array of single-ring polygons.

FunctionSyntax
Pythongeometries(geometry)
SQLST_Geometries(geometry)
Scalageometries(geometry)

For more details, go to the GeoAnalytics for Microsoft Fabric API reference for geometries.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from geoanalytics_fabric.sql import functions as ST
from pyspark.sql import functions as F

data = [
    ("MULTIPOINT (10 10, 20 20, 30 30)",),
    ("MULTILINESTRING ((0 0, 10 10), (10 10, 20 20))", ),
    ("MULTIPOLYGON (((0 0, 5 5, 10 0), (10 0, 15 5, 20 0)))", )
]

df = spark.createDataFrame(data, ["wkt"]).select(ST.geom_from_text("wkt").alias("geometry"))

df.withColumn("geometries", ST.geometries("geometry"))\
    .select("geometries", F.size("geometries").alias("num_parts"))\
    .show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
+-----------------------------------------------------------------------------------+---------+
|geometries                                                                         |num_parts|
+-----------------------------------------------------------------------------------+---------+
|[{"x":10,"y":10}, {"x":20,"y":20}, {"x":30,"y":30}]                                |3        |
|[{"paths":[[[0,0],[10,10]]]}, {"paths":[[[10,10],[20,20]]]}]                       |2        |
|[{"rings":[[[0,0],[5,5],[10,0],[0,0]]]}, {"rings":[[[10,0],[15,5],[20,0],[10,0]]]}]|2        |
+-----------------------------------------------------------------------------------+---------+

Version table

ReleaseNotes

1.0.0-beta

Python, SQL, and Scala functions introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.