Skip to main content

st_makepolygon

Preview

This feature is in Public Preview.

Constructs a polygon from the input outer boundary and optional array of inner boundaries, represented as closed linestrings.

For the corresponding Databricks SQL function, see st_makepolygon function.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

dbf.st_makepolygon(col1=<col1>, col2=<col2>)

Parameters

Parameter

Type

Description

col1

pyspark.sql.Column or str

A Geometry value representing the outer boundary of the polygon.

col2

pyspark.sql.Column, optional

An optional array of Geometry values representing the inner boundaries of the polygon. Default is an empty array.

Examples

Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('LINESTRING(0 0,10 0,10 10,0 10,0 0)',)], ['wkt'])
df.select(dbf.st_astext(dbf.st_makepolygon(dbf.st_geomfromtext('wkt'))).alias('result')).collect()
Output
[Row(result='POLYGON((0 0,10 0,10 10,0 10,0 0))')]