st_distance
Preview
This feature is in Public Preview.
Returns the 2D Cartesian distance between the two input geometries. The units of the result are those of the coordinates of the input geometries.
For the corresponding Databricks SQL function, see st_distance function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.st_distance(col1=<col1>, col2=<col2>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The first Geometry value. |
|
| The second Geometry value. |
Notes
The two geometries are expected to have the same SRID value, otherwise an error is returned.
Examples
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POINT(0 0)','LINESTRING(-10 10,20 10)',)], ['wkt1', 'wkt2'])
df.select(dbf.st_distance(dbf.st_geomfromtext('wkt1'), dbf.st_geomfromtext('wkt2')).alias('result')).collect()
Output
[Row(result=10.0)]