メインコンテンツまでスキップ

h3_kリング距離

元のH3 セル ID からグリッド距離 k 内にあるすべての H3 セル ID (長整数または文字列として表される) と、元の H3 セル ID からの距離を返します。より正確には、結果は構造体の配列であり、各構造体には H3 セル ID (長整数または文字列として表される) と元の H3 セル ID からの距離が含まれます。出力の H3 セル ID の型は、入力 H3 セル ID (式の最初の引数) の型と同じです。Spark Connect をサポートします。

対応する Databricks SQL 関数については、 h3_kringdistances関数を参照してください。

構文

Python
from pyspark.databricks.sql import functions as dbf

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

パラメーター

パラメーター

Type

説明

col1

pyspark.sql.Column または str

または文字列として表される H3 セル ID。

col2

pyspark.sql.Columnstr 、または int

H3 セル ID (最初の引数) からの最大グリッド距離。

Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(599686042433355775, '85283473fffffff', 1,),],['h3l', 'h3s', 'res'])
df.select(dbf.h3_kringdistances('h3l', 'res').alias('result')).collect()
Output
[Row(result=[Row(cellid=599686042433355775, distance=0),     Row(cellid=599686030622195711, distance=1), Row(cellid=599686044580839423, distance=1),     Row(cellid=599686038138388479, distance=1), Row(cellid=599686043507097599, distance=1),     Row(cellid=599686015589810175, distance=1), Row(cellid=599686014516068351, distance=1)])]
Python
df.select(dbf.h3_kringdistances('h3s', 'res').alias('result')).collect()
Output
[Row(result=[Row(cellid='85283473fffffff', distance=0),     Row(cellid='85283447fffffff', distance=1), Row(cellid='8528347bfffffff', distance=1),     Row(cellid='85283463fffffff', distance=1), Row(cellid='85283477fffffff', distance=1),     Row(cellid='8528340ffffffff', distance=1), Row(cellid='8528340bfffffff', distance=1)])]