H3_IS_RES_CLASS_III

Test whether an H3 cell is at a Class III (odd-numbered) resolution in the H3 hierarchy.

Category: h3Returns: BOOLEANDialect: Standard

Syntax

H3_IS_RES_CLASS_III(cell)

Description

## Overview Returns TRUE when the input cell is at an odd-numbered resolution, which in the H3 specification are the Class III resolutions. H3 alternates between two cell classes as you descend the hierarchy: Class II (even resolutions 0, 2, 4, ...) cells are axis-aligned with respect to their parent, while Class III (odd resolutions 1, 3, 5, ...) cells are rotated approximately 19.1 degrees. This alternation allows the aperture-7 hierarchical refinement to fit seven hexagons neatly inside each parent while maintaining near-uniform cell size. Use this when the analysis needs to account for cell orientation, for example when rendering cells, when comparing orientations to a reference grid, or when choosing a resolution that aligns visually with a parent layer. ## Behavior - Returns a BOOLEAN. - Returns TRUE for resolutions 1, 3, 5, 7, 9, 11, 13, and 15. - Returns FALSE for resolutions 0, 2, 4, 6, 8, 10, 12, and 14. - Returns FALSE for NULL or invalid cells (cannot determine class). - The class depends only on the resolution, so the function is equivalent to checking whether H3_GET_RESOLUTION(cell) is odd. - Deterministic: the same cell always returns the same result. ## H3 class reference | Resolution | Class | Orientation vs parent | | --- | --- | --- | | 0, 2, 4, 6, 8, 10, 12, 14 | II | Axis-aligned | | 1, 3, 5, 7, 9, 11, 13, 15 | III | Rotated by arctan(sqrt(3)/5) ~ 19.1 degrees | ## Compatibility - Follows the standard H3 hierarchical hex grid specification for Class II / Class III alternation.

Parameters

NameTypeDescription
cellSpecifies the H3 cell index to test. Must be a valid H3 cell.

Examples

-- Resolutions 1, 3, 5, 7, 9, 11, 13, 15 are Class III.
SELECT H3_IS_RES_CLASS_III(H3_LATLNG_TO_CELL(51.5074, -0.1278, 9)) AS is_class_iii;
-- Resolutions 0, 2, 4, 6, 8, 10, 12, 14 are Class II.
SELECT H3_IS_RES_CLASS_III(H3_LATLNG_TO_CELL(40.7128, -74.0060, 8)) AS is_class_iii;
SELECT
  H3_IS_RES_CLASS_III(H3_LATLNG_TO_CELL(48.8566, 2.3522, 0)) AS res0,
  H3_IS_RES_CLASS_III(H3_LATLNG_TO_CELL(48.8566, 2.3522, 1)) AS res1,
  H3_IS_RES_CLASS_III(H3_LATLNG_TO_CELL(48.8566, 2.3522, 2)) AS res2,
  H3_IS_RES_CLASS_III(H3_LATLNG_TO_CELL(48.8566, 2.3522, 3)) AS res3;
-- Separate Class II (aligned with parent) and Class III (rotated) cells.
SELECT H3_IS_RES_CLASS_III(h3_cell) AS class_iii,
       COUNT(*) AS n
FROM analytics.curated.h3_events_mixed
GROUP BY H3_IS_RES_CLASS_III(h3_cell);

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →