ST_Polygon takes an array column and returns a polygon column. The input column must contain an array of point geometries.
Function | Syntax |
---|---|
Python | polygon(points) |
SQL | ST |
Scala | polygon(points) |
For more details, go to the GeoAnalytics Engine API reference for polygon.
This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.
Examples
from geoanalytics.sql import functions as ST, Point
df = spark.createDataFrame([([Point(0, 0), Point(10, 0), Point(10, 10), Point(0, 10)], )], ["point_array"])
df.select(ST.polygon("point_array").alias("polygon")).show(truncate=False)
Result
+-----------------------------------------------+
|polygon |
+-----------------------------------------------+
|{"rings":[[[0,0],[10,0],[10,10],[0,10],[0,0]]]}|
+-----------------------------------------------+
Version table
Release | Notes |
---|---|
1.0.0 | Python and SQL functions introduced |
1.5.0 | Scala function introduced |