Trifold T3
triangles that nest exactly

A hierarchical triangular discrete global grid system on the icosahedron. Every parent cell is bit-for-bit the union of its four children, something neither hexagons nor pentagons can offer. A ~110 km cell has a 6-character address.

Launch the comparison demo

Built on Trifold: ready-to-use libraries

▲ landcheck: offline land/sea lookup

The first practical proof of concept of exact nesting: the level-10 land classification (~6.15M land-touching cells) collapses into 153,884 run-length intervals: a 182 KB dataset that answers "is this point on land?" in microseconds, fully offline, in Python and JavaScript, with a confidence value for every answer. Optional OSM refinement sharpens coastal answers to a near-exact polygon test.

Info and interactive demo

Next on the roadmap is countrycheck, an offline country lookup using the same run-length approach with border-cell polygons.

landcheck demo: points classified as land, coast and sea on a world map

Benchmarked: 3–30× faster than SQL spatial engines

One workload, four engines: classify 100,000 random points as land or sea against the same OSM land polygons. Trifold-based landcheck answered 3–30× faster than BigQuery, PostGIS and DuckDB Spatial in batch mode and 40–100× faster called one point at a time — true to the name, never less than a three-fold margin. The same gap should apply to similar point-classification problems.

Trifold + OSM
435,463 pts/s
BigQuery
144,092
PostGIS
109,731
DuckDB Spatial
14,605

Batch mode, median of 7 warm runs, Apple M5 Pro, June 2026. The SQL engines compute exact polygon containment; landcheck agrees with them on 99.5% of points from a far smaller dataset. Full benchmark with methodology and caveats →

The idea in 30 seconds

Start from the icosahedron: 20 spherical triangles covering the Earth. Split every triangle into 4 by connecting the great-circle midpoints of its edges. Repeat. Each level halves the edge length and quadruples the cell count (aperture 4). Because children are built from the parent's own vertices plus edge midpoints, a parent cell is exactly the union of its children: aggregating data up the hierarchy or drilling down loses nothing and double-counts nothing.

levelmean edgemean areacells (global)
07,054 km25.5M km²20
3882 km399k km²1,280
6110 km6,226 km²81,920
913.8 km97 km²5.2M
121.7 km1.5 km²336M
15215 m24 ha21.5B
Exact nesting

Parent = union of 4 children, verified to floating-point noise (10⁻¹⁹ of cell area). Lossless multi-resolution aggregation.

Poles and antimeridian

Both poles are lattice vertices: six meridian wedges meet at exactly ±90°. Antimeridian cells use continuous longitudes and are flagged. Classification uses polygon geometry.

Compacted coverage

Interior cells merge up the quadtree as far as they stay wholly on land; coastlines stay fine. 27,614 → 10,046 cells at level 6, identical 171.1M km² coverage.

Three address forms

One identity: compact base32 for humans, digit path for teaching, and a sortable uint64 for compute where a subtree is one contiguous range.

Addressing: one identity, three encodings

A cell is (face, path): one of 20 icosahedron faces plus a base-4 digit per subdivision level (0,1,2 = corner children, 3 = central flipped child). London at level 6:

formexampleforsize
compactTF6958humans, URLs, labels 3 + ⌈2L/5⌉ chars
pathF15-102111teaching, debugging 4 + L chars
addr648811996358392152070compute: sort, join, mask 8 bytes

Each triangle also carries two derived grouping keys. rhombus_id pairs triangles exactly; rhombus_hilbert orders those pairs spatially within ten base diamonds. hex_id provides six-triangle groups inside each icosahedron face, with documented seam and vertex exceptions. These keys do not replace addr64 or change the source geometry.

63 59 5 0 ┌─────────┬────────────────────────────────────────────────────────┬─────┐ │ face:5 │ path digits, 2 bits each, left-aligned │ L:5 │ └─────────┴────────────────────────────────────────────────────────┴─────┘ numeric sort = hierarchical order · ancestor test = shift + compare descendant_range(cell) = inclusive subtree interval
$ pip install -e . && trifold locate -0.1276 51.5072 6
TF6958
$ trifold show TF6958        # → path F15-102111 · edge ~117 km · area 5,864 km²
$ curl https://YOUR-WORKER.workers.dev/locate/-0.1276,51.5072?level=6
{"id":"TF6958","path":"F15-102111","addr64":"8811996358392152070","level":6}

Why base32 instead of digits 0–3? A digit string spends 8 bits per character to carry 2 bits. Crockford base32 packs 5 bits/char with no ambiguous I/L/O/U: same path bits at 40% of the length, URL-safe.

Live demo: 7 grid systems, one map

Trifold triangles vs A5 pentagons, H3 hexagons, S2 quads, rHEALPix, HTM (a related octahedral grid) and a plain lon/lat grid. Each layer uses the same land mask and styling. Toggle globe ↔ flat to compare the globe and Mercator projections; click any cell for its address and properties.

Loading grid data…
Controls

Grid system comparison

T3 (this)A5H3S2rHEALPixHTM/QTM
base solidicosahedrondodecahedronicosahedron cubecube (HEALPix)octahedron
cell shapetrianglepentagonhexagon (+12 pentagons) quadquad (+caps/darts)triangle
aperture / nesting4, exact 4, logical only7, approximate 4, exact9, exact4, exact
equal area~±20%, smoothexact per level ~2× max/minup to ~2×near-exact larger deformation
edge neighbours3 (+9 vertex)5 6 uniform443 (+vertex)
indexuint64, prefix=subtreeuint64, Hilbert uint64uint64, Hilbertstringquadtree string
ecosystemthis repository (2026)introduced in 2025 widely usedwidely used academic / OGCastronomy

Selection depends on the application. H3 provides uniform neighbour traversal and a mature ecosystem; S2 focuses on spatial indexing; rHEALPix and A5 provide equal-area cells. T3 focuses on exact hierarchical aggregation, variable-resolution tilings, and pipelines based on triangular geometry. Full analysis: technical reference.

Suitable uses and limitations

Suitable uses
  • Lossless multi-resolution aggregation: level-9 sums roll into level-6 cells exactly; no slivers, no overlap weighting.
  • Variable-resolution coverage: compacted tilings retain shared boundaries; any subtree is one uint64 range scan.
  • Simplicial pipelines: FEM/FVM meshes, TINs, barycentric interpolation, subdivision surfaces plug in directly.
  • Geodesic properties: no polar singularity; ~±20% smooth area variation worldwide vs 17× collapse for lon/lat at 80°N.
  • Survey/sampling designs where hierarchy beats neighbour traversal.
Limitations
  • Neighbour-heavy algorithms: 3 edge + 9 vertex neighbours with alternating orientation; hexagonal grids provide 6 uniform neighbours.
  • General-audience choropleths: triangle boundaries can be visually prominent.
  • Orientation-sensitive statistics: up/down cells are congruent but rotated 60°.
  • City-scale local work: a projected CRS and planar grid may be simpler.