h3_try_distance

返回同一分辨率的两个 H3 单元格 ID 之间的 H3 网格距离;如果距离未定义,则返回 None

有关相应的 Databricks SQL 函数,请参阅 h3_try_distance 函数

Syntax

from pyspark.databricks.sql import functions as dbf

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

参数

参数 类型 Description
col1 pyspark.sql.Columnstr H3 单元格 ID,表示为 或字符串。
col2 pyspark.sql.Columnstr H3 单元格 ID,表示为 或字符串。

例子

from pyspark.databricks.sql import functions as dbf
df1 = spark.createDataFrame([(599686030622195711, 599686015589810175,)], ['h3l1', 'h3l2'])
df1.select(dbf.h3_try_distance('h3l1', 'h3l2').alias('result')).collect()
[Row(result=2)]
df2 = spark.createDataFrame([(644730217149254377, 644877068142171537,)], ['h3l1', 'h3l2'])
df2.select(dbf.h3_try_distance('h3l1', 'h3l2').alias('result')).collect()
[Row(result=None)]