snowflake.snowpark.functions.h3_try_polygon_to_cells¶
- snowflake.snowpark.functions.h3_try_polygon_to_cells(geography_polygon: 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 polygon at the specified resolution. This is a “try” version that returns None instead of raising an error if the conversion fails.
- Parameters:
geography_polygon (ColumnOrName) – The GEOGRAPHY polygon object.
target_resolution (ColumnOrName) – The H3 resolution level (0-15).
- Returns:
An array of H3 cell IDs as BIGINT values, or None if conversion fails.
- Return type:
Example:
>>> from snowflake.snowpark.functions import to_geography, lit >>> df = session.create_dataframe([ ... ['POLYGON((-122.4 37.8, -122.4 37.7, -122.3 37.7, -122.3 37.8, -122.4 37.8))'] ... ], schema=['polygon_wkt']) >>> df.select( ... h3_try_polygon_to_cells(to_geography(df['polygon_wkt']), lit(5)) ... ).collect() [Row(H3_TRY_POLYGON_TO_CELLS(TO_GEOGRAPHY("POLYGON_WKT"), 5)='[\n 599685771850416127\n]')]