API
HexEarth.Cell
— TypeCell(index::UInt64)
Cell(lonlat::Tuple{<:Real, <:Real}, res::Integer=10)
A hexagonal cell in the H3 grid.
HexEarth.DirectedEdge
— TypeDirectedEdge(a::Cell, b::Cell)
Represents a directional relationship between adjacent cells a
and b
.
HexEarth.GridIJ
— TypeGridIJ(origin::Cell)
Create a 2D grid of cells indexed by (i, j) coordinates relative to an origin cell. Axes are 120° apart.
- Unlike libh3, (0, 0) will always correspond to the origin cell.
- Pentagon distortion may result in some cells having multiple (i, j) coordinates.
- See also
GridIJK
.
HexEarth.GridIJK
— TypeGridIJK(origin::Cell)
Create a 2D grid of cells indexed by (i, j, k) coordinates relative to an origin cell.
- Unlike libh3, (0, 0, 0) will always correspond to the origin cell.
- Note there are multiple valid (i, j, k) coordinates for a given cell.
- See also
GridIJ
.
HexEarth.H3IndexType
— TypeOne of the H3 index types: Cell, Vertex, or DirectedEdge.
HexEarth.Vertex
— TypeVertex(index::UInt64)
Represents a vertex (point on a Cell
boundary) in the H3 grid.
HexEarth.cells
— Functioncells(geometry, res = 10)
cells(polygon, res = 10; containment = nothing)
cells(raster, res = 10; dropmissing = true, dropempty = true, containment = :overlap)
Return a Vector{Cell}
covering the given geometry at the specified H3 resolution (default 10).
- (Multi)polygons allow specifying a
containment
mode:nothing
: (default) use libh3's default polygonToCells behavior (we think this is equivalent to:center
):center
: include cells whose center point is within the polygon:full
: include cells fully contained within the polygon:overlap
: include cells that overlap the polygon at all:overlap_bbox
: include cells that overlap the polygon's bounding box
- Rasters (requires Rasters.jl to be loaded)
HexEarth.grid_disk
— Methodgrid_disk(o::Cell, k::Integer)
Return all cells within k
steps of origin cell o
, including o
itself.
HexEarth.grid_path_cells
— Methodgrid_path_cells(a::Cell, b::Cell)
Return a minimal-length contiguous path of cells from a
to b
.
HexEarth.grid_ring_unsafe
— Methodgrid_ring_unsafe(o::Cell, k::Integer)
Return all cells exactly k
steps from origin cell o
. The order of the returned cells is not guaranteed.
Per h3 documentation, "This function may fail if pentagonal distortion is encountered." We don't know what that means.
HexEarth.resolution
— Methodresolution(::UInt64)
resolution(::Cell)
resolution(::Vertex)
resolution(::DirectedEdge)
Return the resolution 0-15 (coarse to fine) of the given H3 index.
HexEarth.split_index
— Methodsplit_index(x::UInt64) -> NamedTuple
Split a 64-bit H3 index into its fields per the spec:
mode
(4 bits)resolution
(4 bits, 0–15)basecell
(7 bits, 0–121)digits
(15 three-bit digits; unused digits are 7)
References:
- H3 bit layout & cell index fields. See docs.
HexEarth.Geo.R
— ConstantApproximate radius of the earth in meters (WGS84).
HexEarth.Geo.destination
— Methoddestination(x, azimuth°, dist_m)
Find destination point given starting point x
(longitude/latitude in degrees), azimuth
(clockwise from North), and dist_m
(meters).
HexEarth.Geo.haversine
— Methodhaversine(a, b)
Calculate the great-circle distance (meters) between two (lon, lat) points using the Haversine formula. a
and b
are any iterables of length 2 representing (lon, lat).