Share via


h3_pointash3string

Returns the H3 cell ID (as a string) corresponding to the provided point at the specified resolution. The expression emits an error if the geography is not a point or if an error is found when parsing the input representation of the geography. The acceptable input representations are WKT, GeoJSON, and WKB. In the first two cases the input is expected to be of type string, whereas in the last case the input is expected to be of type BINARY. Supports Spark Connect.

For the corresponding Databricks SQL function, see h3_pointash3string function.

Syntax

from pyspark.databricks.sql import functions as dbf

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

Parameters

Parameter Type Description
col1 pyspark.sql.Column or str A string representing a point geography in the WGS84 coordinate reference system in WKT or GeoJSON format, or a BINARY representing a geography in the WGS84 coordinate reference system in WKB format.
col2 pyspark.sql.Column, str, or int The resolution of the H3 cell ID we want to compute that corresponds to the point geography.

Examples

from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POINT(-122.4783 37.8199)', 13),], ['wkt', 'res'])
df.select(dbf.h3_pointash3string('wkt', 'res').alias('result')).collect()
[Row(result='8d283087022a93f')]
df.select(dbf.h3_pointash3string('wkt', 13).alias('result')).collect()
[Row(result='8d283087022a93f')]