API

HexEarth.CellType
Cell(index::UInt64)
Cell(lonlat::Tuple{<:Real, <:Real}, res::Integer=10)

A hexagonal cell in the H3 grid.

source
HexEarth.DirectedEdgeType
DirectedEdge(a::Cell, b::Cell)

Represents a directional relationship between adjacent cells a and b.

source
HexEarth.GridIJType
GridIJ(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.
source
HexEarth.GridIJKType
GridIJK(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.
source
HexEarth.VertexType
Vertex(index::UInt64)

Represents a vertex (point on a Cell boundary) in the H3 grid.

source
HexEarth.cellsFunction
cells(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)
source
HexEarth.grid_diskMethod
grid_disk(o::Cell, k::Integer)

Return all cells within k steps of origin cell o, including o itself.

source
HexEarth.grid_ring_unsafeMethod
grid_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.

source
HexEarth.resolutionMethod
resolution(::UInt64)
resolution(::Cell)
resolution(::Vertex)
resolution(::DirectedEdge)

Return the resolution 0-15 (coarse to fine) of the given H3 index.

source
HexEarth.split_indexMethod
split_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.
source
HexEarth.Geo.destinationMethod
destination(x, azimuth°, dist_m)

Find destination point given starting point x (longitude/latitude in degrees), azimuth (clockwise from North), and dist_m (meters).

source
HexEarth.Geo.haversineMethod
haversine(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).

source