h3_core library

H3 geospatial indexing for Dart/Flutter.

Uses dart:ffi on native, h3-js on web.

Classes

CellBoundary
Cell boundary as an ordered list of vertices in degrees.
CoordIJ
Local IJ coordinate pair for grid-local coordinate operations.
GeoPolygon
Polygon defined by an exterior ring and optional holes, for region operations such as polygonToCells.
H3Version
Version constants for the h3_core package and the underlying H3 C library.
LatLng
Latitude/longitude coordinate pair in degrees.

Enums

ContainmentMode
Containment mode for polygon fill operations.

Extension Types

H3Index
H3 cell, directed edge, or vertex index stored as a hex string.

Functions

areNeighborCells(H3Index origin, H3Index destination) bool
Returns whether origin and destination share an edge.
cellAreaKm2(H3Index cell) double
Returns the exact area of the cell in km².
cellAreaM2(H3Index cell) double
Returns the exact area of the cell in m².
cellsToDirectedEdge(H3Index origin, H3Index destination) H3Index
Returns the directed edge from origin to destination.
cellsToMultiPolygon(List<H3Index> cells) List<List<List<LatLng>>>
Returns the outlines of a set of cells as a GeoJSON-style multi-polygon.
cellToBoundary(H3Index cell) CellBoundary
Returns the boundary vertices of the given H3 cell.
cellToCenterChild(H3Index cell, int childRes) H3Index
Returns the center child of cell at the finer childRes.
cellToChildPos(H3Index child, int parentRes) int
Returns the position of child within its parent at parentRes.
cellToChildren(H3Index cell, int childRes) List<H3Index>
Returns the children of cell at the finer childRes.
cellToLatLng(H3Index cell) LatLng
Returns the center coordinate of the given H3 cell.
cellToLocalIj(H3Index origin, H3Index cell) CoordIJ
Converts cell to local IJ coordinates relative to origin.
cellToParent(H3Index cell, int parentRes) H3Index
Returns the parent cell of cell at the coarser parentRes.
cellToVertex(H3Index cell, int vertexNum) H3Index
Returns the vertex at index vertexNum (0–5) of the cell.
cellToVertexes(H3Index cell) List<H3Index>
Returns all vertices of the given cell.
childPosToCell(int childPos, H3Index parent, int childRes) H3Index
Returns the child cell at childPos within parent at childRes.
compactCells(List<H3Index> cells) List<H3Index>
Compacts a set of cells by replacing complete groups with their parent.
compactCellsAsync(List<H3Index> cells) Future<List<H3Index>>
Async version of compactCells; runs on an isolate on native platforms.
constructCell(int res, int baseCellNumber, List<int> digits) H3Index
Constructs an H3 cell index from res, baseCellNumber, and direction digits.
directedEdgeToBoundary(H3Index edge) CellBoundary
Returns the boundary vertices of the directed edge.
directedEdgeToCells(H3Index edge) List<H3Index>
Returns the origin and destination cells of the directed edge.
edgeLengthKm(H3Index edge) double
Returns the exact length of the directed edge in kilometers.
edgeLengthM(H3Index edge) double
Returns the exact length of the directed edge in meters.
getBaseCellNumber(H3Index h) int
Returns the base cell number (0–121) of the given H3 index.
getDirectedEdgeDestination(H3Index edge) H3Index
Returns the destination cell of the directed edge.
getDirectedEdgeOrigin(H3Index edge) H3Index
Returns the origin cell of the directed edge.
getHexagonAreaAvgKm2(int resolution) double
Returns the average hexagon area in km² at the given resolution.
getHexagonAreaAvgM2(int resolution) double
Returns the average hexagon area in m² at the given resolution.
getHexagonEdgeLengthAvgKm(int resolution) double
Returns the average hexagon edge length in km at the given resolution.
getHexagonEdgeLengthAvgM(int resolution) double
Returns the average hexagon edge length in meters at the given resolution.
getIcosahedronFaces(H3Index h) List<int>
Returns the icosahedron face(s) that the given cell intersects.
getIndexDigit(H3Index h, int resolution) int
Returns the direction digit at the given resolution for index h.
getNumCells(int resolution) int
Returns the total number of cells at the given resolution.
getPentagons(int resolution) List<H3Index>
Returns all 12 pentagon cells at the given resolution.
getRes0Cells() List<H3Index>
Returns all 122 resolution-0 cells.
getResolution(H3Index h) int
Returns the resolution (0–15) of the given H3 index.
greatCircleDistanceKm(LatLng a, LatLng b) double
Returns the great-circle distance between a and b in kilometers.
greatCircleDistanceM(LatLng a, LatLng b) double
Returns the great-circle distance between a and b in meters.
gridDisk(H3Index origin, int k) List<H3Index>
Returns all cells within k grid steps of origin (filled disk).
gridDiskAsync(H3Index origin, int k) Future<List<H3Index>>
Async version of gridDisk; runs on an isolate on native platforms.
gridDiskDistances(H3Index origin, int k) Map<H3Index, int>
Returns cells within k steps of origin mapped to their grid distance.
gridDistance(H3Index origin, H3Index destination) int
Returns the minimum grid distance between origin and destination.
gridPathCells(H3Index start, H3Index end) List<H3Index>
Returns the cells along the shortest grid path from start to end.
gridRing(H3Index origin, int k) List<H3Index>
Returns cells exactly k grid steps from origin (hollow ring).
h3ToString(H3Index h) String
Returns the hex string representation of the given H3 index.
isPentagon(H3Index h) bool
Returns whether h is a pentagon cell.
isResClassIII(H3Index h) bool
Returns whether h has Class III resolution orientation.
isValidCell(H3Index h) bool
Returns whether h is a valid H3 cell index.
isValidDirectedEdge(H3Index edge) bool
Returns whether edge is a valid H3 directed edge index.
isValidIndex(H3Index h) bool
Returns whether h is any valid H3 index (cell, edge, or vertex).
isValidVertex(H3Index vertex) bool
Returns whether vertex is a valid H3 vertex index.
latLngToCell(LatLng latLng, int resolution) H3Index
Converts a latLng coordinate to the H3 cell index at the given resolution (0–15).
localIjToCell(H3Index origin, CoordIJ ij) H3Index
Converts local ij coordinates relative to origin back to an H3 cell.
originToDirectedEdges(H3Index origin) List<H3Index>
Returns all directed edges originating from origin.
pentagonCount() int
Returns the number of pentagons per resolution (always 12).
polygonToCells(GeoPolygon polygon, int resolution) List<H3Index>
Returns all cells whose centers are within the polygon at resolution.
polygonToCellsAsync(GeoPolygon polygon, int resolution) Future<List<H3Index>>
Async version of polygonToCells; runs on an isolate on native platforms.
polygonToCellsExperimental(GeoPolygon polygon, int resolution, {ContainmentMode mode = ContainmentMode.center}) List<H3Index>
Returns cells within the polygon using the specified containment mode.
res0CellCount() int
Returns the number of resolution-0 cells (always 122).
reverseDirectedEdge(H3Index edge) H3Index
Returns the directed edge with origin and destination swapped.
stringToH3(String hex) H3Index
Parses a hex string into an H3Index, throwing H3Exception on invalid input.
uncompactCells(List<H3Index> cells, int resolution) List<H3Index>
Expands compacted cells to the given resolution.
uncompactCellsAsync(List<H3Index> cells, int resolution) Future<List<H3Index>>
Async version of uncompactCells; runs on an isolate on native platforms.
vertexToLatLng(H3Index vertex) LatLng
Returns the coordinates of the given vertex.

Exceptions / Errors

H3Exception
Exception thrown when an H3 operation fails.