st_geomfromwkt
Preview
This feature is in Public Preview. You can confirm preview enrollment on the Previews page. See Manage Databricks previews.
Parses the WKT description and returns the corresponding Geometry value.
For the corresponding Databricks SQL function, see st_geomfromwkt function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.st_geomfromwkt(col1=<col1>, col2=<col2>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| A string in WKT format, representing a geometry value. |
|
| The optional SRID of the geometry. Default is 0. |
Examples
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('LINESTRING(5 6,7 -8)',)], ['wkt'])
df.select(dbf.st_astext(dbf.st_geomfromwkt('wkt')).alias('result')).collect()
Output
[Row(result='LINESTRING(5 6,7 -8)')]
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('LINESTRING(5 6,7 -8)', 3857,)], ['wkt', 'srid'])
df.select(dbf.st_astext(dbf.st_geomfromwkt('wkt', 'srid')).alias('result')).collect()
Output
[Row(result='LINESTRING(5 6,7 -8)')]