Hierarchical grid functions
These functions permit moving between resolutions in the H3 grid system. The functions produce parent (coarser) or children (finer) cells.
h3ToParent
- C
- Python
- Java
- JavaScript (Live)
H3Index h3ToParent(H3Index h, int parentRes);
h3.h3_to_parent(h, parent_res)
long h3ToParent(long h3, int parentRes);
String h3ToParent(String h3Address, int parentRes);
h3.h3ToParent(h3Index, parentRes)
function example() { const h = '85283473fffffff'; return h3v3.h3ToParent(h, 4); }
Returns the parent (coarser) index containing h.
h3ToChildren
- C
- Python
- Java
- JavaScript (Live)
void h3ToChildren(H3Index h, int childRes, H3Index *children);
h3.h3_to_children(h, child_res)
List<Long> h3ToChildren(long h3, int childRes);
List<String> h3ToChildren(String h3Address, int childRes);
h3.h3ToChildren(h3Index, childRes)
function example() { const h = '85283473fffffff'; return h3v3.h3ToChildren(h, 6); }
Populates children with the indexes contained by h at resolution childRes. children must be an array of at least size maxH3ToChildrenSize(h, childRes).
maxH3ToChildrenSize
- C
- Python
- Java
- JavaScript (Live)
int maxH3ToChildrenSize(H3Index h, int childRes);
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.
Returns the parent (coarser) index containing h.
h3ToCenterChild
- C
- Python
- Java
- JavaScript (Live)
H3Index h3ToCenterChild(H3Index h, int childRes);
h3.h3_to_center_child(h3, child_res)
long h3ToCenterChild(long h3, int childRes);
String h3ToCenterChild(String h3, int childRes);
h3.h3ToCenterChild(h, childRes)
function example() { const h = '85283473fffffff'; return h3v3.h3ToCenterChild(h, 7); }
Returns the center child (finer) index contained by h at resolution childRes.
compact
- C
- Python
- Java
- JavaScript (Live)
int compact(const H3Index *h3Set, H3Index *compactedSet, const int numHexes);
h3.compact(hexes)
List<Long> compact(Collection<Long> h3);
List<String> compactAddress(Collection<String> h3);
h3.compact(hexes)
function example() { const h = '85283473fffffff'; const nearby = h3.kRing(h, 4); return h3v3.compact(nearby); }
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.
uncompact
- C
- Python
- Java
- JavaScript (Live)
int uncompact(const H3Index *compactedSet, const int numHexes, H3Index *h3Set, const int maxHexes, const int res);
h3.uncompact(hexes, res)
List<Long> uncompact(Collection<Long> h3, int res);
List<String> uncompactAddress(Collection<String> h3, int res);
h3.uncompact(hexes, res)
function example() { const h = '85283473fffffff'; const nearby = h3.kRing(h, 4); const compacted = h3.compact(nearby); return h3v3.uncompact(compacted, 5); }
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.
maxUncompactSize
- C
- Python
- Java
- JavaScript (Live)
int maxUncompactSize(const H3Index *compactedSet, const int numHexes, const int res)
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.
Returns the size of the array needed by uncompact.