Skip to main content

h3_hexring

Returns an array of H3 cell IDs that form a hollow hexagonal ring centered at the origin H3 cell and that are at grid distance k from the origin H3 cell. Supports Spark Connect.

For the corresponding Databricks SQL function, see h3_hexring function.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

dbf.h3_hexring(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 grid distance from the H3 cell ID (first argument).

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 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_hexring('h3l', 'k').alias('result')).collect()
Output
[Row(result=[599686014516068351, 599686030622195711, 599686044580839423, 599686038138388479,     599686043507097599, 599686015589810175])]
Python
df.select(dbf.h3_hexring('h3l', 1).alias('result')).collect()
Output
[Row(result=[599686014516068351, 599686030622195711, 599686044580839423, 599686038138388479,     599686043507097599, 599686015589810175])]