ST_Points takes a geometry column and returns an array column. For linestring and polygon geometries the function returns the vertices of the input geometry as an array of points. For multipoint and point geometries the function returns an array of all points in the input geometry.
Function | Syntax |
---|---|
Python | points(geometry) |
SQL | ST |
Scala | points(geometry) |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for points.
Examples
from geoanalytics_fabric.sql import functions as ST
data = [
("POINT (10 30)",),
("MULTIPOINT (0 0, 5 5, 0 5)", ),
("LINESTRING (15 15, 10 15, 12 2)", ),
("POLYGON ((20 30, 18 28, 22 35, 40 20))", )
]
df = spark.createDataFrame(data, ["wkt"])\
.select(ST.geom_from_text("wkt").alias("geometry"))
df.select(ST.points("geometry").alias("points")).show(truncate=False)
Result
+--------------------------------------------------------------------+
|points |
+--------------------------------------------------------------------+
|[{"x":10,"y":30}] |
|[{"x":0,"y":0}, {"x":5,"y":5}, {"x":0,"y":5}] |
|[{"x":15,"y":15}, {"x":10,"y":15}, {"x":12,"y":2}] |
|[{"x":20,"y":30}, {"x":18,"y":28}, {"x":22,"y":35}, {"x":40,"y":20}]|
+--------------------------------------------------------------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |