Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of H3 Geospatial Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-h3-geospatial-knowledge-patch)
---
name: h3-geospatial-knowledge-patch
description: H3
version: "4.6.0"
license: MIT
metadata:
author: Nevaberry
---
# H3 geospatial compatibility
Load this skill when working with H3 polygon coverage and outlines, grid
traversal, index inspection and construction, directed edges, shell commands,
or native library integration. Consult the topic references for complete
binding signatures, allocation examples, and output formats.
## Reference index
| Reference | Topics |
| --- | --- |
| [Polygon conversion](references/polygon-conversion.md) | Experimental containment modes and bindings, sizing, linked polygon errors and cleanup, Python outlines, area and latitude corrections |
| [Traversal and indexes](references/traversal-and-indexes.md) | Pentagon-safe rings, unsafe disk layouts, grid paths, digits, construction, validation, faces, directed edges and vertices |
| [CLI and build integration](references/cli-and-build-integration.md) | Polygon and edge commands, index output, argument errors, library installation, pkg-config, custom allocators |
## Compatibility corrections
### C index-digit output type
The inspection reference declares the output parameter of `getIndexDigit` as
`int *`. Match the output variable's type to the declaration in your installed
`<h3api.h>`.
### C polygon conversion and cleanup
In H3 4.5.0, `cellsToMultiPolygon` is internal to the C library. C callers use
the public `cellsToLinkedMultiPolygon` to convert cells to polygon outlines.
Check its return code before using the output polygon:
| Input problem | Error |
| --- | --- |
| Invalid cells | `E_CELL_INVALID` |
| Mixed resolutions | `E_RES_MISMATCH` |
| Duplicate cells | `E_DOMAIN` |
`destroyLinkedMultiPolygon` is safe to call twice on the same linked multipolygon.
### Shell parsing and errors
- `h3 stringToInt` preserves all 16 hexadecimal digits, including directed-edge
and vertex indexes.
- `h3 gridDistance` prints grid steps in decimal; parse the output in base 10.
- Unknown arguments, missing required arguments, and missing or unparseable
argument values cause the `h3` executable to exit with a nonzero status.
- `areNeighborCells` and `isValidDirectedEdge` default to JSON booleans; use
`-f numeric` for `1` or `0`.
### Sizing and numerical corrections
`maxPolygonToCellsSizeExperimental` can estimate very thin or degenerate
polygons without the previously unbounded runtime, including polygons whose
vertices all lie on the same latitude. The unreleased fix for
`maxPolygonToCellsSize` avoids signed integer overflow when summing input
polygon vertex counts.
Passing a negative `k` to `gridRing` no longer causes an out-of-bounds write.
`compactCells` handles large resolution-1 sets, including the complete grid
at that resolution.
`cellAreaRads2`, `cellAreaKm2`, and `cellAreaM2` correct an underestimate for
antimeridian-crossing cells; at resolutions 12 and finer, affected areas could
previously be several percent too small. `cellToLatLng` and `cellToBoundary`
return latitudes accurate to within a few units in the last place, including
near the poles.
## Experimental polygon coverage
Use `polygonToCellsExperimental` for center, full-containment, overlap, or
bounding-box-overlap coverage. The C flags are:
| Mode | C flag | Value |
| --- | --- | --- |
| Cell centers | `CONTAINMENT_CENTER` | 0 |
| Fully contained cells | `CONTAINMENT_FULL` | 1 |
| Cells overlapping at any point | `CONTAINMENT_OVERLAPPING` | 2 |
| Cells whose bounding boxes overlap | `CONTAINMENT_OVERLAPPING_BBOX` | 3 |
Include `<h3api.h>` for the public `ContainmentMode` enum. In C, call
`maxPolygonToCellsSizeExperimental` with the same polygon, resolution, and flag
to obtain an upper bound. Allocate a zeroed `H3Index` buffer and pass its
capacity in elements to `polygonToCellsExperimental`. Both return `E_SUCCESS`
on success. The sizing helper is exposed in C.
Binding mode names and argument order differ; use the complete mapping in
[Polygon conversion](references/polygon-conversion.md). Python and DuckDB use
`center`, `full`, `overlap`, and `bbox_overlap`; Python defaults to `center`.
The shell polygon fill command is the center-based `h3 polygonToCells`.
## Grid traversal
### Rings through pentagon distortion
`gridRing` returns cells exactly `k` grid steps from the origin even when
traversal encounters pentagon distortion. `gridRingUnsafe` can fail there.
In C, use `maxGridRingSize(k, &capacity)` for a zero-initialized `H3Index`
buffer: the maximum is one cell at `k == 0`, or `6 * k` for positive `k`.
Skip zero entries after a successful `gridRing` call.
```sh
h3 gridRing -k 1 -c 85283473fffffff
```
### Disks and paths
Java `gridDiskUnsafe` returns lists grouped by distance and declares
`PentagonEncounteredException`. C `gridDisksUnsafe` groups its flat output by
input cell, then increasing distance; same-distance order is unspecified.
Check for `E_SUCCESS` before using that output because pentagon distortion
can cause traversal to fail.
`h3 gridDiskDistances` defaults to a JSON array of rings indexed by distance.
With `-f newline`, it adds a blank line between rings; preserve those blank
lines when parsing distance groups.
`gridPathCells` supports bidirectional path search between supplied endpoints.
In Go, call `start.GridPath(end)` on the starting cell.
## Index inspection and construction
`getIndexDigit` reads positions 1–15 from cell, directed-edge, or vertex
indexes. Position 1 is the resolution-1 digit; valid cells return `7` for
unused positions beyond their resolution.
In C, `constructCell(res, baseCellNumber, digits, &cell)` takes resolution
0–15, base cell 0–121, and `res` digits from 0–6 in resolution order. The
digit pointer may be `NULL` at resolution 0. On `E_SUCCESS`, `cell` holds the
constructed index.
| Construction failure | Error |
| --- | --- |
| Invalid resolution | `E_RES_DOMAIN` |
| Invalid base cell | `E_BASE_CELL_DOMAIN` |
| Invalid digit | `E_DIGIT_DOMAIN` |
| Pentagon base cell whose first nonzero digit is `1` | `E_DELETED_DIGIT` |
The CLI infers resolution from the digit count; supplied `-r` must equal that
count. Use `--format newline` for a bare cell index.
```sh
h3 constructCell -b 0 -d 0 --format newline
```
C `isValidIndex` returns `1` for a valid cell, directed edge, or vertex and
`0` otherwise. The CLI exposes `h3 isValidIndex` for mixed index types.
For C face inspection, size the `int` buffer with `maxFaceCount`, scan all
capacity entries after successful `getIcosahedronFaces`, and skip `-1` values.
## Directed edges
`reverseDirectedEdge` swaps an edge's origin and destination; an invalid
directed-edge index returns an error. `edgeToVertexes` obtains the two H3
vertex indexes at the ends of a directed edge.
```sh
h3 reverseDirectedEdge -e 115283473fffffff # "115283477fffffff"
```
Use `-o` and `-d` for `areNeighborCells` and `cellsToDirectedEdge`. Use `-c`
for `isValidDirectedEdge`, `getDirectedEdgeOrigin`,
`getDirectedEdgeDestination`, `directedEdgeToCells`, and `directedEdgeToBoundary`.
`h3 originToDirectedEdges -c <cell>` defaults to a JSON array. Use `-f newline`
for one unquoted index per line; this format also works with
`cellsToDirectedEdge`, `getDirectedEdgeOrigin`, `getDirectedEdgeDestination`,
and `directedEdgeToCells`.
JavaScript `h3.directedEdgeToBoundary` defaults to `[lat, lng]` pairs. Pass
`true` as the second argument for GeoJSON `[lng, lat]` order.
## Shell polygon workflows and native integration
`h3 polygonToCells` accepts resolutions 0–15 and `[lat, lng]` pairs through
`--polygon` (up to 1,500 characters), `--file`, or stdin with `--file --`.
It emits JSON by default or one cell per line with `--format newline`.
`h3 cellsToMultiPolygon` converts cells to JSON or WKT outlines; inline
`--cells` input accepts up to 100 hexadecimal cells. Use file or stdin input
for larger sets.
`CMAKE_INSTALL_LIBDIR` selects the library installation directory. The `h3`
pkg-config module supplies compiler and linker flags for the installed C
library. `H3_MEMORY_PREFIX` configures replacement memory-management functions
with the specified prefix.
```sh
pkg-config --cflags --libs h3
```