Skip to main content
Version: 3.x

Hierarchical grid functions

These functions permit moving between resolutions in the H3 grid system. The functions produce parent (coarser) or children (finer) cells.


H3Index h3ToParent(H3Index h, int parentRes);

Returns the parent (coarser) index containing h.


void h3ToChildren(H3Index h, int childRes, H3Index *children);

Populates children with the indexes contained by h at resolution childRes. children must be an array of at least size maxH3ToChildrenSize(h, childRes).


int maxH3ToChildrenSize(H3Index h, int childRes);

Returns the parent (coarser) index containing h.


H3Index h3ToCenterChild(H3Index h, int childRes);

Returns the center child (finer) index contained by h at resolution childRes.


int compact(const H3Index *h3Set, H3Index *compactedSet, const int numHexes);

Compacts the set h3Set of indexes as best as possible, into the array compactedSet. compactedSet must be at least the size of h3Set in case the set cannot be compacted.

Returns 0 on success.


int uncompact(const H3Index *compactedSet, const int numHexes, H3Index *h3Set, const int maxHexes, const int res);

Uncompacts the set compactedSet of indexes to the resolution res. h3Set must be at least of size maxUncompactSize(compactedSet, numHexes, res).

Returns 0 on success.


int maxUncompactSize(const H3Index *compactedSet, const int numHexes, const int res)

Returns the size of the array needed by uncompact.