snowflake.snowpark.functions.h3_polygon_to_cells¶

snowflake.snowpark.functions.h3_polygon_to_cells(geography_polygon: Union[snowflake.snowpark.column.Column, str], target_resolution: Union[snowflake.snowpark.column.Column, str]) → Column[source]¶

Returns the H3 cell IDs contained by the input polygon at the specified resolution.

Parameters:
  • geography_polygon (ColumnOrName) – A GEOGRAPHY object representing a polygon.

  • target_resolution (ColumnOrName) – The H3 resolution (0-15).

Returns:

An array of H3 cell IDs as integers.

Return type:

Column

Example::
>>> from snowflake.snowpark.functions import to_geography, lit
>>> df = session.create_dataframe([
...     ['POLYGON((-122.481889 37.826683,-122.479487 37.808548,-122.474150 37.808904,-122.476510 37.826935,-122.481889 37.826683))']
... ], schema=["polygon_wkt"])
>>> df.select(h3_polygon_to_cells(to_geography(df["polygon_wkt"]), lit(9))).collect()
[Row(H3_POLYGON_TO_CELLS(TO_GEOGRAPHY("POLYGON_WKT"), 9)='[\n  617700171177525247,\n  617700171225497599,\n  617700171167563775,\n  617700171167825919,\n  617700171188011007,\n  617700171168350207,\n  617700171168612351,\n  617700171176476671,\n  617700171168874495\n]')]
Copy