Skip to main content
Version: 4.x (alpha)

Hierarchical grid functions

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


H3Error cellToParent(H3Index cell, int parentRes, H3Index *parent);

Provides the parent (coarser) index containing cell.

Returns 0 (E_SUCCESS) on success.


H3Error cellToChildren(H3Index cell, int childRes, H3Index *children);

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

Returns 0 (E_SUCCESS) on success.


H3Error cellToChildrenSize(H3Index cell, int childRes, int64_t *out);

Provides the size of the children array needed for the given inputs to cellToChildren.

Returns 0 (E_SUCCESS) on success.


H3Index cellToCenterChild(H3Index cell, int childRes);

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


H3Error compactCells(const H3Index *cellSet, H3Index *compactedSet, const int numCells);

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

Returns 0 (E_SUCCESS) on success.


H3Error uncompactCells(const H3Index *compactedSet, const int numCells, H3Index *cellSet, const int maxCells, const int res);

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

Returns 0 (E_SUCCESS) on success.


H3Error uncompactCellsSize(const H3Index *compactedSet, const int64_t numCompacted, const int res, int64_t *out);

Places the size of the array needed by uncompactCells into out.

Returns 0 (E_SUCCESS) on success.