Index inspection functions
These functions provide metadata about an H3 index, such as its resolution or base cell, and provide utilities for converting into and out of the 64-bit representation of an H3 index.
getResolution
Returns the resolution of the index. (Works for cells, edges, and vertexes.)
- C
- Java
- JavaScript (Live)
- Python
- Shell
int getResolution(H3Index h);
int getResolution(long h3);
int getResolution(String h3Address);
h3.getResolution(h)
h3.get_resolution(h)
$ h3 getResolution --help
h3: Extracts the resolution (0 - 15) from the H3 cell
H3 4.1.0
getResolution Extracts the resolution (0 - 15) from the H3 cell
-h, --help Show this help message.
-c, --cell <index> Required. H3 Cell
$ h3 getResolution -c 85283473fffffff
5
getBaseCellNumber
Returns the base cell number of the index. (Works for cells, edges, and vertexes.)
- C
- Java
- JavaScript (Live)
- Python
- Shell
int getBaseCellNumber(H3Index h);
int getBaseCellNumber(long h3);
int getBaseCellNumber(String h3Address);
h3.getBaseCellNumber(h)
h3.get_base_cell_number(h)
$ h3 getBaseCellNumber --help
h3: Extracts the base cell number (0 - 121) from the H3 cell
H3 4.1.0
getBaseCellNumber Extracts the base cell number (0 - 121) from the H3 cell
-h, --help Show this help message.
-c, --cell <index> Required. H3 Cell
$ h3 getBaseCellNumber -c 85283473fffffff
20
stringToH3
Converts the string representation to H3Index
(uint64_t
) representation.
- C
- Java
- JavaScript (Live)
- Python
- Shell
H3Error stringToH3(const char *str, H3Index *out);
Returns 0 (E_SUCCESS
) on success.
long stringToH3(String h3Address);
The H3 JavaScript binding supports only the string representation of an H3 index.
h3.str_to_int(h)
The H3 CLI supports only the string representation of an H3 index.
h3ToString
Converts the H3Index
representation of the index to the string representation.
- C
- Java
- JavaScript (Live)
- Python
- Shell
H3Error h3ToString(H3Index h, char *str, size_t sz);
str
must be at least of length 17.
Returns 0 (E_SUCCESS
) on success.
String h3ToString(long h3);
The H3 JavaScript binding supports only the string representation of an H3 index.
h3.int_to_str(h)
The H3 CLI supports only the string representation of an H3 index.
isValidCell
Returns non-zero if this is a valid H3 cell index.
- C
- Java
- JavaScript (Live)
- Python
- Shell
int isValidCell(H3Index h);
boolean isValidCell(long h3);
boolean isValidCell(String h3Address);
h3.isValidCell(h)
h3.is_valid_cell(h)
$ h3 isValidCell --help
h3: Checks if the provided H3 index is actually valid
H3 4.1.0
isValidCell Checks if the provided H3 index is actually valid
-h, --help Show this help message.
-c, --cell <index> Required. H3 Cell
-f, --format <FMT> 'json' for true or false, 'numeric' for 1 or 0 (Default: json)
$ h3 isValidCell -c 85283473fffffff
true
isResClassIII
Returns non-zero if this index has a resolution with Class III orientation.
- C
- Java
- JavaScript (Live)
- Python
- Shell
int isResClassIII(H3Index h);
boolean isResClassIII(long h3);
boolean isResClassIII(String h3Address);
h3.isResClassIII(h)
h3.is_res_class_III(h)
$ h3 isResClassIII --help
h3: Checks if the provided H3 index has a Class III orientation
H3 4.1.0
isResClassIII Checks if the provided H3 index has a Class III orientation
-h, --help Show this help message.
-c, --cell <index> Required. H3 Cell
-f, --format <FMT> 'json' for true or false, 'numeric' for 1 or 0 (Default: json)
$ h3 isResClassIII -c 85283473fffffff
true
isPentagon
Returns non-zero if this index represents a pentagonal cell.
- C
- Java
- JavaScript (Live)
- Python
- Shell
int isPentagon(H3Index h);
boolean isPentagon(long h3);
boolean isPentagon(String h3Address);
h3.isPentagon(h)
h3.is_pentagon(h)
$ h3 isPentagon --help
h3: Checks if the provided H3 index is a pentagon instead of a hexagon
H3 4.1.0
isPentagon Checks if the provided H3 index is a pentagon instead of a hexagon
-h, --help Show this help message.
-c, --cell <index> Required. H3 Cell
-f, --format <FMT> 'json' for true or false, 'numeric' for 1 or 0 (Default: json)
$ h3 isPentagon -c 85283473fffffff
false
getIcosahedronFaces
Find all icosahedron faces intersected by a given H3 cell. Faces are represented as integers from 0-19, inclusive.
- C
- Java
- JavaScript (Live)
- Python
- Shell
H3Error getIcosahedronFaces(H3Index h, int* out);
Face values are placed in the array out
.
out
must be at least length of maxFaceCount(h)
.
The array is sparse, and empty (no intersection) array values are represented by -1.
Returns 0 (E_SUCCESS
) on success.
Collection<Integer> getIcosahedronFaces(long h3);
Collection<Integer> getIcosahedronFaces(String h3Address);
h3.getIcosahedronFaces(h)
h3.get_icosahedron_faces(h)
$ h3 getIcosahedronFaces --help
h3: Returns the icosahedron face numbers (0 - 19) that the H3 index intersects
H3 4.1.0
getIcosahedronFaces Returns the icosahedron face numbers (0 - 19) that the H3 index intersects
-h, --help Show this help message.
-c, --cell <index> Required. H3 Cell
-f, --format <FMT> 'json' for [faceNum, ...], 'newline' for faceNum\n... (Default: json)
$ h3 getIcosahedronFaces -c 85283473fffffff
[7]
maxFaceCount
Returns the maximum number of icosahedron faces the given H3 index may intersect.
- C
- Java
- JavaScript (Live)
- Python
- Shell
H3Error maxFaceCount(H3Index h3, int *out);
Returns 0 (E_SUCCESS
) on success.
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.
This function exists for memory management and is not exposed.