Share via


st_distancesphere

Important

This feature is in Public Preview.

Returns the spherical distance (in meters) between two point geometries, measured on a sphere whose radius is the mean radius of the WGS84 ellipsoid.

For the corresponding Databricks SQL function, see st_distancesphere function.

Syntax

from pyspark.databricks.sql import functions as dbf

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

Parameters

Parameter Type Description
col1 pyspark.sql.Column or str The first Geometry value.
col2 pyspark.sql.Column or str The second Geometry value.

Notes

The two geometries are expected to have the same SRID value. The coordinates of the two point geometries are expected to be longitudes and latitudes in degrees, in that order.

Examples

from pyspark.databricks.sql import functions as dbf
from pyspark.sql.functions.builtin import round
df = spark.createDataFrame([('POINT(2 3)','POINT ZM (6 7 23 1000)',)], ['wkt1', 'wkt2'])
df.select(round(dbf.st_distancesphere(dbf.st_geomfromtext('wkt1'), dbf.st_geomfromtext('wkt2')), 3).alias('result')).collect()
[Row(result=627753.245)]