---
id: vertex
title: Vertex functions
sidebar_label: Vertexes
slug: /api/vertex
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Vertex mode allows encoding the topological vertexes of H3 cells.

## cellToVertex

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">

```c
H3Error cellToVertex(H3Index origin, int vertexNum, H3Index *out);
```

Returns 0 (`E_SUCCESS`) on success.

</TabItem>
<TabItem value="java">

```java
Long cellToVertex(long origin, int vertexNum);
String cellToVertex(String origin, int vertexNum);
```

</TabItem>
<TabItem value="javascript">

```js
h3.cellToVertex(origin, vertexNum)
```

```js live
function example() {
  const h = '85283473fffffff';
  const vertexNum = 2;
  return h3.cellToVertex(h, vertexNum);
}
```

</TabItem>
<TabItem value="python">

```py
h3.cell_to_vertex(origin, vertex_num)
```

</TabItem>
<TabItem value="go">

```go
h3.CellToVertex(origin, vertexNum)
```

</TabItem>
<TabItem value="duckdb">

```sql
h3_cell_to_vertex(origin, vertex_num)
```

</TabItem>
<TabItem value="shell">

```sh
$ 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)
```

```bash
$ h3 cellToVertex -v 2 -c 85283473fffffff
"205283463fffffff"
```

</TabItem>
</Tabs>

## cellToVertexes

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">

```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.

</TabItem>
<TabItem value="java">

```java
List<Long> cellToVertexes(long origin);
List<String> cellToVertexes(String origin);
```

</TabItem>
<TabItem value="javascript">

```js
h3.cellToVertexes(origin)
```

```js live
function example() {
  const h = '85283473fffffff';
  return h3.cellToVertexes(h);
}
```

</TabItem>
<TabItem value="python">

```py
h3.cell_to_vertexes(origin)
```

</TabItem>
<TabItem value="go">

```go
h3.CellToVertexes(origin)
```

</TabItem>
<TabItem value="duckdb">

```sql
h3_cell_to_vertexes(origin)
```

</TabItem>
<TabItem value="shell">

```sh
$ 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)
```

```bash
$ h3 cellToVertexes -c 85283473fffffff
[ "22528340bfffffff", "235283447fffffff", "205283463fffffff", "255283463fffffff", "22528340ffffffff", "23528340bfffffff" ]
```

</TabItem>
</Tabs>

## vertexToLatLng

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">

```c
H3Error vertexToLatLng(H3Index vertex, LatLng *point);
```

Returns 0 (`E_SUCCESS`) on success.

</TabItem>
<TabItem value="java">

```java
LatLng vertexToLatLng(long vertex);
LatLng vertexToLatLng(String vertex);
```

</TabItem>
<TabItem value="javascript">

```js
h3.vertexToLatLng(vertex)
```

```js live
function example() {
  const h = '255283463fffffff';
  return h3.vertexToLatLng(h);
}
```

</TabItem>
<TabItem value="python">

```py
h3.vertex_to_latlng(vertex)
```

</TabItem>
<TabItem value="go">

```go
h3.VertexToLatLng(vertex)
```

</TabItem>
<TabItem value="duckdb">

```sql
h3_vertex_to_latlng(vertex)
```

</TabItem>
<TabItem value="shell">

```sh
$ 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)
```

```bash
$ h3 vertexToLatLng -c 255283463fffffff
[37.4201286777, -122.0377349643]
```

</TabItem>
</Tabs>

## isValidVertex

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">

```c
int isValidVertex(H3Index vertex);
```

Returns 1 if the given index represents a valid H3 vertex.

</TabItem>
<TabItem value="java">

```java
boolean isValidVertex(long vertex);
boolean isValidVertex(String vertex);
```

</TabItem>
<TabItem value="javascript">

```js
h3.isValidVertex(vertex)
```

```js live
function example() {
  const h = '255283463fffffff';
  return h3.isValidVertex(h);
}
```

</TabItem>
<TabItem value="python">

```py
h3.is_valid_vertex(vertex)
```

</TabItem>
<TabItem value="go">

```go
h3.IsValidVertex(vertex)
```

</TabItem>
<TabItem value="duckdb">

```sql
h3_is_valid_vertex(vertex)
```

</TabItem>
<TabItem value="shell">

```sh
$ 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)
```

```bash
$ h3 isValidVertex -c 255283463fffffff
true
```

</TabItem>
</Tabs>
