Skip to main content

Hierarchical hexagonal grid on an octahedral earth projection

Project description

hhg9 / Hex9

This is Hex9 is an ongoing project exploring (and developing) a novel hierarchical hexagonal grid (HHG) system for global projections. It is well-suited to population mapping, environmental modeling, heat-mapping, hex-binning, and other geospatial analyses.

Why hexagonal tiling

  • Hexagonal tiling is unique among regular tilings: all neighbors share an edge.
  • Hexagonal tiling corresponds to optimal circle packing.
  • However...
    • Hexagons cannot be tiled with hexagons.
    • The sphere cannot be covered by hexagonal tilings
  • So, although ideal HHG have a long history in geospatial modeling...
    • Most global HHG are either flat or approximate, or not entirely hexagonal.
    • Existing approaches involve trade-offs, such as
      • Approximating the sphere with slight distortions.
      • Limiting the number of hierarchical layers.
      • Supporting only partial support for transitions between layers.
      • Deriving the hexagonal grid from spherical geometry
      • Needing precomputed databases of fixed points.
      • Requiring additional polygon types (commonly pentagons) for closure
  • Hex9 presents a new approach to the “holy grail” of HHG; It aims to reduce some of these constraints while remaining early-stage and not yet production-ready (Summer 2025).

Why Hex9

Grid-Projection Decoupling

The Hex9 grid is fully decoupled from the underlying global projection. The logical hex grid exists independently of any coordinate reference system and can be applied within any octahedral global projection. While Hex9 comes with a derived projection for this project, the grid itself is projection-agnostic, while the derived projection relies on the Hex9 grid for root-finding operations.

This separation ensures:

  • The grid can be reused across projections without loss of structure.
  • Analyses and visualizations remain consistent, regardless of map distortions in the underlying projection.

Accuracy

Hex9 supports near-lossless forward and inverse mappings between grid addresses and geodetic coordinates. Accuracy is maintained even at extreme resolution: At layer 30, hexagons are on the order of 1µm. Example round-trip accuracy for several landmarks:

The grid addresses below are non-canonical, but representative (grid addressing is prone to change)

Great Pyramid

29°58'44.985076680004"N, 31°8'3.346883880003"E (Reference Coordinates)
EAV484520284815335765361106218588821C2 (Grid Address)
29°58'44.985076680016"N, 31°8'3.346883879965"E (Roundtrip via Grid Address)
∂1.028579nm delta (Geodesic.DISTANCE)

Stonehenge

51°10'43.672800075871"N, 1°49'34.031280757836"W (Reference Coordinates)
NWΛ013572475462870330106251202683087C4 (Grid Address)
51°10'43.672800075819"N, 1°49'34.031280757874"W (Roundtrip via Grid Address)
∂1.314516nm delta (Geodesic.DISTANCE)

Moai on Rapa Nui

27°7'32.827199567155"S, 109°16'36.740870832014"W (Reference Coordinates)
SWΛ145666784771136056604063805344505A7 (Grid Address)
27°7'32.827199567155"S, 109°16'36.740870832014"W (Roundtrip via Grid Address)
∂0.000000nm  delta (Geodesic.DISTANCE)

North Pole (edge case)

90°0'0.000000000000"N, 0°0'0.000000000000"E (Reference Coordinates)
NAV333333333333333333333333333333324G3 (Grid Address)
89°59'59.999999999847"N, 50°11'39.944067845317"E (Roundtrip via Grid Address)
∂4.761801nm  delta (Geodesic.DISTANCE)

Intuitive uint64 Addresses

While mixed text addresses are used above, Hex9 supports various uint64 addresses in a directly intuitive manner.

The fastest is region (triangle-grid) based, with each digit representing the sub-region of its parent region. This provides a global accuracy of 0.30m².

For example, one of the Nazca Spirals - at 14.679806S, 75.101925W has the uint64 address 0xE8254A1913954600 (in hexadecimal). The first bit is set to 1, and identifies this as a global address. The next 3 bits indicate the octant. E:1110 indicates octant id 6 (SWA).

0xE8254...
  ↑↑↑↑↑
  ||||└─── Layer 4, region 4
  |||└──── Layer 3, region 5
  ||└───── Layer 2, region 2
  |└────── Layer 1, region 8
  └─────── 0x80 | octant (6)

When the uint64 address is depicted in hexadecimal, the global address is revealed and may be readily eye-balled with a crib - see the following image that traces the first 5 regions 8,2,5,4,A - each one covering 1/9th the area of the preceding layer.

Performance

Hex9 efficiently handles large datasets. For example, 25 million sparse GCD points can be mapped in far less than 20 minutes on standard desktop hardware.

Summary

Thanks to its decoupled, fractal-based structure, Hex9 allows direct projection of spatial data onto hexagonal grids. It has strong roundtrip integrity. It is reasonably authalic, with a global RSME of about 7%, but smooth authalic change - meaning that at local levels, data sampling is representative.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hhg9-0.1.0a0.tar.gz (113.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hhg9-0.1.0a0-py3-none-any.whl (119.8 kB view details)

Uploaded Python 3

File details

Details for the file hhg9-0.1.0a0.tar.gz.

File metadata

  • Download URL: hhg9-0.1.0a0.tar.gz
  • Upload date:
  • Size: 113.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for hhg9-0.1.0a0.tar.gz
Algorithm Hash digest
SHA256 262632bccf2a1691f176d16dda1600c2943d72ee66ebaae4cfed814119dc0a0b
MD5 e4c74cd6e8bc58d5f48e8e195db0459b
BLAKE2b-256 86e78dbc10343e2d69480ce13ec1a41a0149ff5b0ae17747b76ad4ae91fbefc1

See more details on using hashes here.

File details

Details for the file hhg9-0.1.0a0-py3-none-any.whl.

File metadata

  • Download URL: hhg9-0.1.0a0-py3-none-any.whl
  • Upload date:
  • Size: 119.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for hhg9-0.1.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 b678c5e29d7f0ef482ebf20c791ea9a26c4b568bc4dea0b58253b5d5c53d6d84
MD5 ba6eb4ff6b862edf75f667f2282c3f5f
BLAKE2b-256 d795bd22101f2330be2a618b95888bc704af5549d6011305a32d1687676463a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page