Hierarchical grid functions
These functions permit moving between resolutions in the H3 grid system. The functions produce parent cells (coarser), or child cells (finer).
cellToParent
- C
- Python
- Java
- JavaScript (Live)
H3Error cellToParent(H3Index cell, int parentRes, H3Index *parent);
h3.cell_to_parent(cell, parent_res)
long cellToParent(long cell, int parentRes);
String cellToParent(String cellAddress, int parentRes);
h3.cellToParent(cell, parentRes)
Provides the parent (coarser) index containing cell
.
Returns 0 (E_SUCCESS
) on success.
cellToChildren
- C
- Python
- Java
- JavaScript (Live)
H3Error cellToChildren(H3Index cell, int childRes, H3Index *children);
h3.cell_to_children(cell, child_res)
List<Long> cellToChildren(long cell, int childRes);
List<String> cellToChildren(String cellAddress, int childRes);
h3.cellToChildren(cell, childRes)
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.
cellToChildrenSize
- C
- Python
- Java
- JavaScript (Live)
H3Error cellToChildrenSize(H3Index cell, int childRes, int64_t *out);
This function exists for memory management and is not exposed.
This function exists for memory management and is not exposed.
This function exists for memory management and is not exposed.
Provides the size of the children
array needed for the given inputs to cellToChildren
.
Returns 0 (E_SUCCESS
) on success.
cellToCenterChild
- C
- Python
- Java
- JavaScript (Live)
H3Error cellToCenterChild(H3Index cell, int childRes, H3Index *child);
h3.cell_to_center_child(cell, child_res)
long cellToCenterChild(long cell, int childRes);
String cellToCenterChild(String cellAddress, int childRes);
h3.cellToCenterChild(cell, childRes)
Provides the center child (finer) index contained by cell
at resolution childRes
.
Returns 0 (E_SUCCESS
) on success.
cellToChildPos
- C
- Python
- Java
- JavaScript (Live)
H3Index cellToChildPos(H3Index child, int parentRes, int64_t *out);
h3.cell_to_child_pos(child, parent_res)
long cellToChildPos(long child, int parentRes);
long cellToChildPos(String childAddress, int parentRes);
h3.cellToChildPos(child, parentRes)
Returns the position of the child cell within an ordered list of all children of the cell's parent at the specified resolution parentRes
. The order of the ordered list is the same as that returned by cellToChildren
. This is the complement of childPosToCell
.
Returns 0 (E_SUCCESS
) on success.
childPosToCell
- C
- Python
- Java
- JavaScript (Live)
H3Index childPosToCell(int64_t childPos, H3Index parent, int childRes, H3Index *child);
h3.cell_to_child_pos(child_pos, parent, child_res)
long childPosToCell(long childPos, long parent, int childRes);
String childPosToCell(long childPos, String parentAddress, int childRes);
h3.childPosToCell(childPos, parent, childRes);
Returns the child cell at a given position within an ordered list of all children of parent
at the specified resolution childRes
. The order of the ordered list is the same as that returned by cellToChildren
. This is the complement of cellToChildPos
.
Returns 0 (E_SUCCESS
) on success.
compactCells
- C
- Python
- Java
- JavaScript (Live)
H3Error compactCells(const H3Index *cellSet, H3Index *compactedSet, const int64_t numCells);
h3.compact_cells(cells)
List<Long> compactCells(Collection<Long> cells);
List<String> compactCellAddress(Collection<String> cells);
h3.compactCells(cells)
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. Cells in cellSet
must all share the same resolution.
Returns 0 (E_SUCCESS
) on success.
uncompactCells
- C
- Python
- Java
- JavaScript (Live)
H3Error uncompactCells(const H3Index *compactedSet, const int64_t numCells, H3Index *cellSet, const int64_t maxCells, const int res);
h3.uncompact_cells(cells, res)
List<Long> uncompactCells(Collection<Long> cells, int res);
List<String> uncompactCellAddress(Collection<String> cells, int res);
h3.uncompactCells(cells, 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.
uncompactCellsSize
- C
- Python
- Java
- JavaScript (Live)
H3Error uncompactCellsSize(const H3Index *compactedSet, const int64_t numCompacted, const int res, int64_t *out);
This function exists for memory management and is not exposed.
This function exists for memory management and is not exposed.
This function exists for memory management and is not exposed.
Places the size of the array needed by uncompactCells
into out
.
Returns 0 (E_SUCCESS
) on success.