ST_GeomFromSparkGeom takes a Spark GEOMETRY column and returns a GeoAnalytics Engine geometry column.
This function should only be used when you don't know the types of geometries in the input column or when the input column contains more than one geometry type. In other cases, use the function specific to the geometry type of your input data (i.e. ST_PointFromSparkGeom, ST_LineFromSparkGeom, ST_MPointFromSparkGeom, or ST_PolyFromSparkGeom).
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.
| Function | Syntax |
|---|---|
| Python | geom |
| SQL | ST |
| Scala | geom |
For more details, go to the GeoAnalytics Engine API reference for geom_from_spark_geom.
Examples
from geoanalytics.sql import functions as ST
data = [
("POINT (-2533858.73 8107527.81)",),
("LINESTRING (-3636954.77 7750916.26, -3168756.90 7966747.98, -3124795.45 7893415.62)", )
]
df = spark.createDataFrame(data, ["wkt"]) \
.select(ST.as_spark_geom(ST.geom_from_text("wkt", sr=3857)).alias("spark_geom"))
df.select(ST.as_text(ST.geom_from_spark_geom("spark_geom")).alias("esri_geom")).show(truncate=False)+----------------------------------------------------------------------------------+
|esri_geom |
+----------------------------------------------------------------------------------+
|POINT (-2533858.73 8107527.81) |
|LINESTRING (-3636954.77 7750916.26, -3168756.9 7966747.98, -3124795.45 7893415.62)|
+----------------------------------------------------------------------------------+Version table
| Release | Notes |
|---|---|
2.2.0 | Python, SQL, and Scala functions introduced |