重要
此功能目前以公共预览版提供。 可以在预览页面上确认加入状态。 请参阅 管理 Azure Databricks 预览版。
返回第一个几何图形上一个点的 2D 投影,该几何图形相对于 Euclidean 距离最接近第二个几何图形。
有关相应的 Databricks SQL 函数,请参阅 st_closestpoint 函数。
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.st_closestpoint(col1=<col1>, col2=<col2>)
参数
| 参数 | 类型 | Description |
|---|---|---|
col1 |
pyspark.sql.Column 或 str |
第一个 Geometry 值。 |
col2 |
pyspark.sql.Column 或 str |
第二个 Geometry 值。 |
注释
这两个几何图形应具有相同的 SRID 值,否则将返回错误。 返回点的 SRID 值与输入几何图形的常见 SRID 值相同。 如果两个输入几何图形中的任何一个为空,则返回 2D 空点。
例子
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('MULTIPOINT ZM (-10 10 -1 -10,2 10 -2 -20,20 10 -3 -30)','POINT Z (0 0 300)',)], ['wkt1', 'wkt2'])
df.select(dbf.st_asewkt(dbf.st_closestpoint(dbf.st_geomfromtext('wkt1', 3857), dbf.st_geomfromtext('wkt2', 3857)).alias('result'))).collect()
[Row(result='SRID=3857;POINT(2 10)')]