---
id: inspection
title: Index inspection functions
sidebar_label: Inspection
slug: /api/inspection
---

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

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

<Tabs
  groupId="language"
  defaultValue="c"
  values={[
    {label: 'C', value: 'c'},
    {label: 'Java', value: 'java'},
    {label: 'JavaScript (Live)', value: 'javascript'},
    {label: 'Python', value: 'python'},
    {label: 'Shell', value: 'shell'},
  ]
}>
<TabItem value="c">

```c
int getResolution(H3Index h);
```

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

```java
int getResolution(long h3);
int getResolution(String h3Address);
```

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

```js
h3.getResolution(h)
```

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

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

```py
h3.get_resolution(h)
```

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

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

```bash
$ h3 getResolution -c 85283473fffffff
5
```

</TabItem>
</Tabs>


## getBaseCellNumber

Returns the base cell number of the index.
(Works for cells, edges, and vertexes.)

<Tabs
  groupId="language"
  defaultValue="c"
  values={[
    {label: 'C', value: 'c'},
    {label: 'Java', value: 'java'},
    {label: 'JavaScript (Live)', value: 'javascript'},
    {label: 'Python', value: 'python'},
    {label: 'Shell', value: 'shell'},
  ]
}>
<TabItem value="c">

```c
int getBaseCellNumber(H3Index h);
```

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

```java
int getBaseCellNumber(long h3);
int getBaseCellNumber(String h3Address);
```

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

```js
h3.getBaseCellNumber(h)
```

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

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

```py
h3.get_base_cell_number(h)
```

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

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

```bash
$ h3 getBaseCellNumber -c 85283473fffffff
20
```

</TabItem>
</Tabs>

## stringToH3

Converts the string representation to `H3Index` (`uint64_t`) representation.

<Tabs
  groupId="language"
  defaultValue="c"
  values={[
    {label: 'C', value: 'c'},
    {label: 'Java', value: 'java'},
    {label: 'JavaScript (Live)', value: 'javascript'},
    {label: 'Python', value: 'python'},
    {label: 'Shell', value: 'shell'},
  ]
}>
<TabItem value="c">

```c
H3Error stringToH3(const char *str, H3Index *out);
```

Returns 0 (`E_SUCCESS`) on success.

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

```java
long stringToH3(String h3Address);
```

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

:::note

The H3 JavaScript binding supports only the string representation of an H3 index.

:::

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

```py
h3.str_to_int(h)
```

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

:::note

The H3 CLI supports only the string representation of an H3 index.

:::


</TabItem>
</Tabs>

## h3ToString

Converts the `H3Index` representation of the index to the string representation.

<Tabs
  groupId="language"
  defaultValue="c"
  values={[
    {label: 'C', value: 'c'},
    {label: 'Java', value: 'java'},
    {label: 'JavaScript (Live)', value: 'javascript'},
    {label: 'Python', value: 'python'},
    {label: 'Shell', value: 'shell'},
  ]
}>
<TabItem value="c">

```c
H3Error h3ToString(H3Index h, char *str, size_t sz);
```

`str` must be at least of length 17.
Returns 0 (`E_SUCCESS`) on success.

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

```java
String h3ToString(long h3);
```

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

:::note

The H3 JavaScript binding supports only the string representation of an H3 index.

:::

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

```py
h3.int_to_str(h)
```

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

:::note

The H3 CLI supports only the string representation of an H3 index.

:::

</TabItem>
</Tabs>



## isValidCell

Returns non-zero if this is a valid H3 cell index.

<Tabs
  groupId="language"
  defaultValue="c"
  values={[
    {label: 'C', value: 'c'},
    {label: 'Java', value: 'java'},
    {label: 'JavaScript (Live)', value: 'javascript'},
    {label: 'Python', value: 'python'},
    {label: 'Shell', value: 'shell'},
  ]
}>
<TabItem value="c">

```c
int isValidCell(H3Index h);
```

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

```java
boolean isValidCell(long h3);
boolean isValidCell(String h3Address);
```

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

```js
h3.isValidCell(h)
```

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

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

```py
h3.is_valid_cell(h)
```

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

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

```bash
$ h3 isValidCell -c 85283473fffffff
true
```

</TabItem>
</Tabs>


## isResClassIII

Returns non-zero if this index has a resolution with Class III orientation.

<Tabs
  groupId="language"
  defaultValue="c"
  values={[
    {label: 'C', value: 'c'},
    {label: 'Java', value: 'java'},
    {label: 'JavaScript (Live)', value: 'javascript'},
    {label: 'Python', value: 'python'},
    {label: 'Shell', value: 'shell'},
  ]
}>
<TabItem value="c">

```c
int isResClassIII(H3Index h);
```

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

```java
boolean isResClassIII(long h3);
boolean isResClassIII(String h3Address);
```

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

```js
h3.isResClassIII(h)
```

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

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

```py
h3.is_res_class_III(h)
```

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

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

```bash
$ h3 isResClassIII -c 85283473fffffff
true
```

</TabItem>
</Tabs>


## isPentagon

Returns non-zero if this index represents a pentagonal 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: 'Shell', value: 'shell'},
  ]
}>
<TabItem value="c">

```c
int isPentagon(H3Index h);
```

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

```java
boolean isPentagon(long h3);
boolean isPentagon(String h3Address);
```

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

```js
h3.isPentagon(h)
```

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

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

```py
h3.is_pentagon(h)
```

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

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

```bash
$ h3 isPentagon -c 85283473fffffff
false
```

</TabItem>
</Tabs>


## getIcosahedronFaces

Find all icosahedron faces intersected by a given H3 cell.
Faces are represented as integers from 0-19, inclusive.

<Tabs
  groupId="language"
  defaultValue="c"
  values={[
    {label: 'C', value: 'c'},
    {label: 'Java', value: 'java'},
    {label: 'JavaScript (Live)', value: 'javascript'},
    {label: 'Python', value: 'python'},
    {label: 'Shell', value: 'shell'},
  ]
}>
<TabItem value="c">

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

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

```java
Collection<Integer> getIcosahedronFaces(long h3);
Collection<Integer> getIcosahedronFaces(String h3Address);
```

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

```js
h3.getIcosahedronFaces(h)
```

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

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

```py
h3.get_icosahedron_faces(h)
```

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

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

```bash
$ h3 getIcosahedronFaces -c 85283473fffffff
[7]
```
</TabItem>
</Tabs>

## maxFaceCount

Returns the maximum number of icosahedron faces the given H3 index may intersect.

<Tabs
  groupId="language"
  defaultValue="c"
  values={[
    {label: 'C', value: 'c'},
    {label: 'Java', value: 'java'},
    {label: 'JavaScript (Live)', value: 'javascript'},
    {label: 'Python', value: 'python'},
    {label: 'Shell', value: 'shell'},
  ]
}>
<TabItem value="c">

```c
H3Error maxFaceCount(H3Index h3, int *out);
```

Returns 0 (`E_SUCCESS`) on success.

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

:::note

This function exists for memory management and is not exposed.

:::

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

:::note

This function exists for memory management and is not exposed.

:::

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

:::note

This function exists for memory management and is not exposed.

:::

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

:::note

This function exists for memory management and is not exposed.

:::

</TabItem>
</Tabs>
