
ST_Boundary takes a geometry column and returns a geometry column. The output column contains the topological boundary of the given geometry. The function will return a linestring if the input is a polygon and a multipoint if the input is a linestring. Point and multipoint inputs are not supported.
Function | Syntax |
---|---|
Python | boundary(geometry) |
SQL | ST |
Scala | boundary(geometry) |
For more details, go to the GeoAnalytics Engine API reference for boundary.
This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.1.
Examples
from geoanalytics.sql import functions as ST
data = [
("POINT (10, 30)",),
("MULTIPOINT (0 0, 10 10, 20 20)", ),
("LINESTRING (0 0, 10 10, 20 20)", ),
("POLYGON ((0 0, 5 5, 10 0, 20 10))", )
]
df = spark.createDataFrame(data, ["wkt"])\
.select(ST.geom_from_text("wkt").alias("geometry"))
df.select(ST.boundary("geometry").alias("boundary")).show(truncate=False)
Result
+----------------------------------------------+
|boundary |
+----------------------------------------------+
|NULL |
|NULL |
|{"points":[[0,0],[20,20]]} |
|{"paths":[[[0,0],[20,10],[10,0],[5,5],[0,0]]]}|
+----------------------------------------------+
Version table
Release | Notes |
---|---|
1.0.0 | Python and SQL functions introduced |
1.5.0 | Scala function introduced |