ST_PointN takes a geometry column and an integer and returns a point column. The output column represents
the nth point in the input geometry, where 0
is the first point. If the nth point does not exist
the function returns null
. This function always returns null
for multipart linestrings and multipart polygons.
Function | Syntax |
---|---|
Python | point |
SQL | ST |
Scala | point |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for point_n.
This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.
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))", ),
("MULTILINESTRING ((0 0, 10 10), (10 10, 20 20))", )
]
df = spark.createDataFrame(data, ["wkt"])\
.select(ST.geom_from_text("wkt").alias("geometry"))
df.select(ST.point_n("geometry", 2).alias("point_n")).show()
Result
+---------------+
| point_n|
+---------------+
| NULL|
| {"x":0,"y":5}|
| {"x":12,"y":2}|
|{"x":22,"y":35}|
| NULL|
+---------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |