Return the H3 hierarchy resolution of a cell as an integer 0 through 15.
H3_GET_RESOLUTION(cell)
## Overview Returns the resolution (level in the H3 hierarchy) of the given cell as an integer in the range 0 through 15. Every H3 cell carries its resolution in the low bits of its ID; this function extracts it directly without any computation or I/O. It is the cheapest way to find out what level a cell occupies and is used throughout H3 pipelines to validate inputs, partition queries, and roll cells up to a common comparison level. Use it whenever you accept H3 input from a user, from storage, or from a join where the resolution may vary. ## Behavior - Returns an INT in the range [0, 15]. - Returns NULL if the input is NULL or not a valid H3 cell index. - The operation is O(1): the resolution is encoded directly in the cell ID. - Deterministic: the same cell always returns the same resolution. - Both hexagon and pentagon cells report a resolution from 0 to 15; the pentagon flag is separate (see H3_IS_PENTAGON). ## H3 resolution reference | Res | Average edge length | Average hex area | | --- | --- | --- | | 0 | 1,107 km | 4.25 million km^2 | | 4 | 22.6 km | 1,770 km^2 | | 7 | 1.22 km | 5.16 km^2 | | 9 | 174 m | 0.11 km^2 | | 12 | 9.4 m | 307 m^2 | | 15 | 0.5 m | 0.9 m^2 | ## Compatibility - Follows the standard H3 hierarchical hex grid specification for resolution extraction.
| Name | Type | Description |
|---|---|---|
cell | Specifies the H3 cell index whose resolution to return. Must be a valid H3 cell. |
-- Expect 9.
SELECT H3_GET_RESOLUTION(H3_LATLNG_TO_CELL(51.5074, -0.1278, 9)) AS res;
-- Check for mixed-resolution contamination in a supposedly res-9 column.
SELECT H3_GET_RESOLUTION(h3_cell) AS res, COUNT(*) AS n
FROM analytics.curated.h3_events_res9
GROUP BY H3_GET_RESOLUTION(h3_cell)
ORDER BY res;
-- Keep only resolution 7 cells from a heterogeneous ingest.
SELECT cell_id
FROM spatial.reference.h3_cells
WHERE H3_GET_RESOLUTION(cell_id) = 7;
-- Roll every cell up to a shared resolution 5 for comparison.
SELECT event_id,
H3_CELL_TO_PARENT(h3_cell, 5) AS h3_res5
FROM analytics.curated.h3_events_mixed
WHERE H3_GET_RESOLUTION(h3_cell) >= 5;