Share via


st_distancespheroid

Important

This feature is in Public Preview.

Returns the geodesic distance (in meters) between two point geometries on the WGS84 ellipsoid.

For the corresponding Databricks SQL function, see st_distancespheroid function.

Syntax

from pyspark.databricks.sql import functions as dbf

dbf.st_distancespheroid(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_distancespheroid(dbf.st_geomfromtext('wkt1'), dbf.st_geomfromtext('wkt2')), 3).alias('result')).collect()
[Row(result=626380.599)]