ST_PolyFromSparkGeom takes a Spark GEOMETRY column and returns a GeoAnalytics Engine polygon column.

This function is supported with Spark 4.2.0 and above. The function can also be used with Spark 4.1.x after setting spark.sql.geospatial.enabled to true in the Spark configuration.

FunctionSyntax
Pythonpoly_from_spark_geom(geometry)
SQLST_PolyFromSparkGeom(geometry)
ScalapolyFromSparkGeom(geometry)

For more details, go to the GeoAnalytics Engine API reference for poly_from_spark_geom.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9

from geoanalytics.sql import functions as ST

data = [("POLYGON ((-117.271 34.059, -117.225 33.919, -116.963 33.662, -116.668 33.712))",),]

df = spark.createDataFrame(data, ["wkt"]) \
          .select(ST.as_spark_geom(ST.poly_from_text("wkt", sr=4326)).alias("spark_geom"))

df.select(ST.as_text(ST.poly_from_spark_geom("spark_geom")).alias("esri_geom")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+-----------------------------------------------------------------------------------------------+
|esri_geom                                                                                      |
+-----------------------------------------------------------------------------------------------+
|POLYGON ((-117.271 34.059, -117.225 33.919, -116.963 33.662, -116.668 33.712, -117.271 34.059))|
+-----------------------------------------------------------------------------------------------+

Version table

ReleaseNotes

2.2.0

Python, SQL, and Scala functions introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.