h3_try_tessellateaswkb
Returns an array of structs representing the chips covering geography at the specified resolution, or null if the geometry is invalid. More precisely, the elements of the returned array are named structs with three fields names "cellid", "core", and "chip":
- The "cellid" field contains one of the H3 cells covering the input geography.
- The "core" field determines if the boundary polygon of the H3 cell in the "cellid" field is contained inside the input geography. This can happen only for areal input geographies. If the cell is contained in the input geography the value is set to
True, andfalseotherwise. - The "chip" field is the (Cartesian) intersection of the H3 cell polygon, corresponding to the H3 cell id in the "cellid" field, with the input geography, represented in WKB format. The set of the H3 cells ids returned as the "cellid" elements of the structs in the array is a minimal covering set for the input geography.
For the corresponding Databricks SQL function, see h3_try_tessellateaswkb function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.h3_try_tessellateaswkb(col1=<col1>, col2=<col2>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| A string representing a geography in the WGS84 coordinate reference system in WKT or GeoJSON format, or a BINARY representing a linear or areal geography in the WGS84 coordinate reference system in WKB format. |
|
| The resolution of the H3 cell IDs that cover the geography. |
Examples
Python
from pyspark.databricks.sql import functions as dbf
from pyspark.sql import functions as f
df = spark.createDataFrame([('MULTIPOINT(20 0,20 10,40 30)', 0),], ['wkt', 'res'])
chips = df.select(f.inline(dbf.h3_try_tessellateaswkb('wkt', 'res')).alias('cell', 'core', 'chip'))
chips.select(dbf.h3_h3tostring('cell').alias('cell'),dbf.st_astext(dbf.st_geomfromwkb('chip')).alias('wkt')).collect()
Output
[Row(cell='802dfffffffffff', wkt='POINT(40 30)'), Row(cell='806bfffffffffff', wkt='MULTIPOINT((20 0),(20 10))')]