Skip to content
Back to skills

H3 Geospatial Knowledge Patch

ASecurity

H3

  • 25 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 5, 2026
developmentjavascriptpythongojavashellgitapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill h3-geospatial-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of H3 Geospatial Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for H3 Geospatial Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-h3-geospatial-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-h3-geospatial-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: h3-geospatial-knowledge-patch
description: H3
version: "4.6.0"
license: MIT
metadata:
  author: Nevaberry
---



# H3 Geospatial Knowledge Patch

Load this skill when working with H3 polygon coverage and outlines, grid
traversal, directed edges, index inspection and construction, shell automation,
or native library configuration. Use the references for binding signatures,
complete examples, and the attribution of individual changes.

## Reference index

| Reference | Topics |
| --- | --- |
| [CLI automation and native packaging](references/cli-and-packaging.md) | Polygon and edge commands, formats, argument errors, index conversion, CMake, pkg-config |
| [Grid traversal and directed edges](references/grid-traversal.md) | Safe rings, unsafe disks, paths, edge reversal, endpoint vertices, boundary coordinate order |
| [Index APIs](references/index-apis.md) | Digits, construction, validation, C identifiers, face lists, area and latitude precision |
| [Polygon conversion and containment](references/polygon-conversion.md) | Experimental containment modes, sizing, bindings, compaction, linked polygons, Python result types |

## Compatibility checks and changed behavior

### Match the installed C 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>`. See [Index APIs](references/index-apis.md).

### Use the public C outline conversion

In H3 4.5.0, `cellsToMultiPolygon` is internal to the C library. C callers use
`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.

### Account for CLI parsing and formatting

The `h3` executable exits with a nonzero status for unknown arguments, missing
required arguments, and missing or unparseable argument values.

`h3 stringToInt` preserves all 16 hexadecimal digits, including directed-edge
and vertex indexes. `h3 gridDistance` prints decimal grid steps; parse in base 10.

For `h3 gridDiskDistances` with `-f newline`, preserve the extra blank line between
rings when parsing distance groups.

### Keep sizing fixes scoped to their APIs

`maxPolygonToCellsSizeExperimental` can now estimate very thin or degenerate
polygons without the previously unbounded runtime, including polygons whose
vertices all share a latitude.

The unreleased fix for `maxPolygonToCellsSize` avoids signed integer overflow
when summing the input polygon's vertex counts.

### Account for geometry and traversal fixes

`cellAreaRads2`, `cellAreaKm2`, and `cellAreaM2` correct an underestimate for cells
crossing the antimeridian. 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.

Passing a negative `k` to `gridRing` no longer causes an out-of-bounds write.

## Experimental polygon containment

`polygonToCellsExperimental` supports coverage by cell centers, fully contained
cells, cells overlapping the polygon at any point, or cells whose bounding boxes
overlap it. Include `<h3api.h>` for the public C `ContainmentMode` enum.

| Coverage | C flag | Python and DuckDB mode |
| --- | --- | --- |
| Cell center | `CONTAINMENT_CENTER` (0) | `center` |
| Full containment | `CONTAINMENT_FULL` (1) | `full` |
| Any overlap | `CONTAINMENT_OVERLAPPING` (2) | `overlap` |
| Bounding-box overlap | `CONTAINMENT_OVERLAPPING_BBOX` (3) | `bbox_overlap` |

In C, call `maxPolygonToCellsSizeExperimental` with the same polygon, resolution,
and flag; allocate a zeroed `H3Index` buffer and pass its capacity in elements to
`polygonToCellsExperimental`. Both calls return `E_SUCCESS` on success.

Python accepts `LatLngPoly` or `LatLngMultiPoly` in
`h3.h3shape_to_cells_experimental(shape, res, contain="overlap")`; its default mode
is `center`. JavaScript, Java, Go, and DuckDB use the binding forms documented in
[Polygon conversion and containment](references/polygon-conversion.md).

The sizing helper is exposed in C. The shell polygon fill command is the
center-based `h3 polygonToCells`.

## Rings, disks, and paths

`gridRing` returns cells exactly `k` grid steps from the origin even when traversal
encounters pentagon distortion. `gridRingUnsafe` can fail on that distortion.

In C, `maxGridRingSize(k, &capacity)` sizes a zero-initialized `H3Index` buffer:
the maximum is one cell at `k == 0`, or `6 * k` for positive `k`. After a successful
`gridRing`, skip zero entries.

Java `gridDiskUnsafe` exposes `gridDiskDistancesUnsafe`, returning cells grouped
by distance as `List<List<Long>>` or `List<List<String>>`; both overloads declare
`PentagonEncounteredException`.

In C, `gridDisksUnsafe(origins, count, k, out)` groups a flat array by input cell,
then increasing distance. Order within one distance is unspecified. Check for
`E_SUCCESS` before using output because pentagon distortion can cause failure.

`gridPathCells` supports bidirectional path search between supplied endpoints.
In Go, call `start.GridPath(end)` on the starting cell.

## Directed edges

`reverseDirectedEdge` writes an edge with origin and destination swapped; an
invalid directed-edge index returns an error. Use `edgeToVertexes` for the two
H3 vertex indexes at the ends of a directed edge.

For JavaScript `h3.directedEdgeToBoundary`, pass `true` as the second argument for
`[lng, lat]` pairs. The default order is `[lat, lng]`.

For the CLI, pass `-o` and `-d` to `areNeighborCells` and `cellsToDirectedEdge`.
Use `-c` for `isValidDirectedEdge`, `getDirectedEdgeOrigin`,
`getDirectedEdgeDestination`, `directedEdgeToCells`, and `directedEdgeToBoundary`.
The reversal command uses `-e`.

`areNeighborCells` and `isValidDirectedEdge` default to JSON booleans; `-f numeric`
returns `1` or `0`. Outgoing-edge and edge-conversion commands support unquoted
indexes with `-f newline`; see the CLI reference for the exact command list.

## Inspect, construct, and validate indexes

`getIndexDigit` reads positions 1–15 from a cell, directed edge, or vertex index.
Position 1 is the resolution-1 digit. Valid cells return `7` at unused positions
beyond their resolution.

In C, `constructCell(res, baseCellNumber, digits, &cell)` accepts 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. `E_SUCCESS` means `cell` holds the constructed index.

Invalid resolution, base cell, and digit values return `E_RES_DOMAIN`,
`E_BASE_CELL_DOMAIN`, and `E_DIGIT_DOMAIN`, respectively. A pentagon base cell
returns `E_DELETED_DIGIT` if its first nonzero digit is `1`.

`h3 constructCell` infers resolution from digit count; an explicit `-r` must equal
that count. Use `--format newline` for a bare cell index in shell pipelines.

The C predicate `int isValidIndex(H3Index h)` returns `1` for valid cells, directed
edges, or vertices and `0` otherwise. Java, DuckDB, and the CLI also expose
validation across these index types.

For C face inspection, size an `int` buffer with `maxFaceCount(cell, &capacity)`.
After successful `getIcosahedronFaces(cell, faces)`, scan all `capacity` entries
and skip `-1` values.

## Polygon results and shell input

`compactCells` handles large resolution-1 cell sets, including the complete grid
at that resolution.

Python `h3.cells_to_h3shape(cells)` returns a `LatLngPoly` for a single-polygon
outline and a `LatLngMultiPoly` otherwise. Pass `tight=False` to always get a
`LatLngMultiPoly`.

`h3 polygonToCells` accepts resolutions 0–15 and `[lat, lng]` pairs through
`--polygon` (up to 1,500 characters), `--file <filename>`, or stdin with
`--file --`. It defaults to JSON; `--format newline` emits one cell per line.

`h3 cellsToMultiPolygon` converts cells to JSON or WKT outlines. It accepts up to
100 hexadecimal cells inline with `--cells`; use `--file <filename>` for larger
sets or `--file --` for stdin.

## Native configuration

`CMAKE_INSTALL_LIBDIR` selects the library installation directory. The
`H3_MEMORY_PREFIX` CMake option configures replacement memory-management
functions with the specified prefix.

H3 provides `h3.pc`; use `pkg-config --cflags --libs h3` for compiler and linker
flags for the installed C library.

Files in this skill

  • SKILL.md8.1 KB
  • coverage.json719 B
  • references/cli-and-packaging.md1.5 KB
  • references/grid-traversal.md1.7 KB
  • references/index-apis.md2.3 KB
  • references/polygon-conversion.md2.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.