Skip to main content

h3_kring

Returns the H3 cell IDs that are within (grid) distance k of the origin cell ID. Supports Spark Connect.

For the corresponding Databricks SQL function, see h3_kring function.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

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

Parameters

Parameter

Type

Description

col1

pyspark.sql.Column or str

An H3 cell ID, represented as a Column or string.

col2

pyspark.sql.Column, str, or int

The maximum grid distance from the H3 cell ID (first argument).

Examples

Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(599686042433355775, 1,)], ['h3l', 'k'])
df.select(dbf.h3_kring('h3l', 'k').alias('result')).collect()
Output
[Row(result=[599686042433355775, 599686030622195711, 599686044580839423, 599686038138388479,     599686043507097599, 599686015589810175, 599686014516068351])]
Python
df.select(dbf.h3_kring('h3l', 1).alias('result')).collect()
Output
[Row(result=[599686042433355775, 599686030622195711, 599686044580839423, 599686038138388479,     599686043507097599, 599686015589810175, 599686014516068351])]