h3_pointash3
Returns the H3 cell ID (as int) 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_pointash3 function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.h3_pointash3(col1=<col1>, col2=<col2>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| 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. |
|
| 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_pointash3('wkt', 'res').alias('result')).collect()
[Row(result=635714569676958015)]
df.select(dbf.h3_pointash3('wkt', 13).alias('result')).collect()
[Row(result=635714569676958015)]