snowflake.snowpark.functions.h3_try_coverage¶
- snowflake.snowpark.functions.h3_try_coverage(geography_expression: Union[snowflake.snowpark.column.Column, str], target_resolution: Union[snowflake.snowpark.column.Column, str]) Column [source]¶
Returns an array of H3 cell IDs that cover the given geography at the specified resolution. This function attempts to provide coverage of the geography using H3 cells, returning None if the operation cannot be performed.
- Parameters:
geography_expression (ColumnOrName) – The geography object to cover with H3 cells.
target_resolution (ColumnOrName) – The H3 resolution level (0-15) for the coverage.
- Returns:
An array of H3 cell IDs covering the geography or None if the operation cannot be performed.
- Return type:
- Example::
>>> from snowflake.snowpark.functions import to_geography, lit >>> df = session.create_dataframe([ ... ("POLYGON((-122.4194 37.7749, -122.4094 37.7749, -122.4094 37.7849, -122.4194 37.7849, -122.4194 37.7749))",) ... ], schema=["geog"]) >>> df.select(h3_try_coverage(to_geography(df["geog"]), lit(9)).alias("coverage")).collect() [Row(COVERAGE='[\n 617700169957507071,\n 617700169958031359,\n 617700169958293503,\n 617700169961701375,\n 617700169961963519,\n 617700169962487807,\n 617700169963012095,\n 617700169963798527,\n 617700169964060671,\n 617700169964322815,\n 617700169964584959,\n 617700169964847103,\n 617700169965109247,\n 617700169965371391,\n 617700170001809407,\n 617700170002857983,\n 617700170017800191\n]')]