website/docs/api/vertex.mdx
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
Vertex mode allows encoding the topological vertexes of H3 cells.
Returns the index for the specified cell vertex. Valid vertex numbers are between 0 and 5 (inclusive) for hexagonal cells, and 0 and 4 (inclusive) for pentagonal cells.
<Tabs groupId="language" defaultValue="c" values={[ {label: 'C', value: 'c'}, {label: 'Java', value: 'java'}, {label: 'JavaScript (Live)', value: 'javascript'}, {label: 'Python', value: 'python'}, {label: 'Go', value: 'go'}, {label: 'DuckDB', value: 'duckdb'}, {label: 'Shell', value: 'shell'}, ] }> <TabItem value="c">
H3Error cellToVertex(H3Index origin, int vertexNum, H3Index *out);
Returns 0 (E_SUCCESS) on success.
Long cellToVertex(long origin, int vertexNum);
String cellToVertex(String origin, int vertexNum);
h3.cellToVertex(origin, vertexNum)
function example() {
const h = '85283473fffffff';
const vertexNum = 2;
return h3.cellToVertex(h, vertexNum);
}
h3.cell_to_vertex(origin, vertex_num)
h3.CellToVertex(origin, vertexNum)
h3_cell_to_vertex(origin, vertex_num)
$ h3 cellToVertex --help
h3: Returns the vertex for the specified cell and vertex index. Must be 0-5 for hexagons, 0-4 for pentagons
H3 4.1.0
cellToVertex Returns the vertex for the specified cell and vertex index. Must be 0-5 for hexagons, 0-4 for pentagons
-c, --cell <index> Required. H3 Cell
-v, --vertex <INDEX> Required. Vertex index number. 0-5 for hexagons, 0-4 for pentagons
-h, --help Show this help message.
-f, --format <FMT> 'json' for "CELL"\n, 'newline' for CELL\n (Default: json)
$ h3 cellToVertex -v 2 -c 85283473fffffff
"205283463fffffff"
Returns the indexes for all vertexes of the given cell.
<Tabs groupId="language" defaultValue="c" values={[ {label: 'C', value: 'c'}, {label: 'Java', value: 'java'}, {label: 'JavaScript (Live)', value: 'javascript'}, {label: 'Python', value: 'python'}, {label: 'DuckDB', value: 'duckdb'}, {label: 'Go', value: 'go'}, {label: 'Shell', value: 'shell'}, ] }> <TabItem value="c">
H3Error cellToVertexes(H3Index origin, H3Index *out);
The length of the out array must be 6.
If the given cell is a pentagon, one member of the
array will be set to 0.
Returns 0 (E_SUCCESS) on success.
List<Long> cellToVertexes(long origin);
List<String> cellToVertexes(String origin);
h3.cellToVertexes(origin)
function example() {
const h = '85283473fffffff';
return h3.cellToVertexes(h);
}
h3.cell_to_vertexes(origin)
h3.CellToVertexes(origin)
h3_cell_to_vertexes(origin)
$ h3 cellToVertexes --help
h3: Returns all of the vertexes from the specified cell
H3 4.1.0
cellToVertexes Returns all of the vertexes from the specified cell
-c, --cell <index> Required. H3 Cell
-h, --help Show this help message.
-f, --format <FMT> 'json' for ["CELL", ...], 'newline' for CELL\n... (Default: json)
$ h3 cellToVertexes -c 85283473fffffff
[ "22528340bfffffff", "235283447fffffff", "205283463fffffff", "255283463fffffff", "22528340ffffffff", "23528340bfffffff" ]
Returns the latitude and longitude coordinates of the given vertex.
<Tabs groupId="language" defaultValue="c" values={[ {label: 'C', value: 'c'}, {label: 'Java', value: 'java'}, {label: 'JavaScript (Live)', value: 'javascript'}, {label: 'Python', value: 'python'}, {label: 'Go', value: 'go'}, {label: 'DuckDB', value: 'duckdb'}, {label: 'Shell', value: 'shell'}, ] }> <TabItem value="c">
H3Error vertexToLatLng(H3Index vertex, LatLng *point);
Returns 0 (E_SUCCESS) on success.
LatLng vertexToLatLng(long vertex);
LatLng vertexToLatLng(String vertex);
h3.vertexToLatLng(vertex)
function example() {
const h = '255283463fffffff';
return h3.vertexToLatLng(h);
}
h3.vertex_to_latlng(vertex)
h3.VertexToLatLng(vertex)
h3_vertex_to_latlng(vertex)
$ h3 vertexToLatLng --help
h3: Returns the lat, lng pair for the given vertex
H3 4.1.0
vertexToLatLng Returns the lat, lng pair for the given vertex
-c, --cell <index> Required. H3 Cell
-h, --help Show this help message.
-f, --format <FMT> 'json' for [lat, lng], 'wkt' for a WKT POINT, 'newline' for lat\nlng\n (Default: json)
$ h3 vertexToLatLng -c 255283463fffffff
[37.4201286777, -122.0377349643]
Determines if the given H3 index represents a valid H3 vertex.
<Tabs groupId="language" defaultValue="c" values={[ {label: 'C', value: 'c'}, {label: 'Java', value: 'java'}, {label: 'JavaScript (Live)', value: 'javascript'}, {label: 'Python', value: 'python'}, {label: 'Go', value: 'go'}, {label: 'DuckDB', value: 'duckdb'}, {label: 'Shell', value: 'shell'}, ] }> <TabItem value="c">
int isValidVertex(H3Index vertex);
Returns 1 if the given index represents a valid H3 vertex.
</TabItem> <TabItem value="java">boolean isValidVertex(long vertex);
boolean isValidVertex(String vertex);
h3.isValidVertex(vertex)
function example() {
const h = '255283463fffffff';
return h3.isValidVertex(h);
}
h3.is_valid_vertex(vertex)
h3.IsValidVertex(vertex)
h3_is_valid_vertex(vertex)
$ h3 isValidVertex --help
h3: Checks if the provided H3 vertex is actually valid
H3 4.1.0
isValidVertex Checks if the provided H3 vertex 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 isValidVertex -c 255283463fffffff
true