重要
此功能目前以公共预览版提供。
返回两个点几何图形之间的球面距离(以米为单位),该几何图形的半径是 WGS84 椭圆的平均值半径。
有关相应的 Databricks SQL 函数,请参阅 st_distancesphere 函数。
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.st_distancesphere(col1=<col1>, col2=<col2>)
参数
| 参数 | 类型 | Description |
|---|---|---|
col1 |
pyspark.sql.Column 或 str |
第一个 Geometry 值。 |
col2 |
pyspark.sql.Column 或 str |
第二个 Geometry 值。 |
注释
这两个几何图形应具有相同的 SRID 值。 这两个点几何图形的坐标应为经度和纬度(以度为单位)。
例子
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)]