Go implementation of A5, a geospatial index that partitions the world into pentagonal cells.
Cells are available at 31 different resolution levels, with the largest cell covering the whole world, and the smallest less than 30mm². Within each resolution level the cells have equal area, as per the OGC definition.
For more information, see the A5 documentation.
go get github.com/a5geo/a5-gopackage main
import (
"fmt"
a5 "github.com/a5geo/a5-go"
)
func main() {
// Convert coordinates to a cell ID
lonLat := a5.LonLat{-73.9857, 40.7484} // New York City
cellID, _ := a5.LonLatToCell(lonLat, 10)
fmt.Printf("Cell ID: %d\n", cellID)
// Convert a cell ID back to coordinates
center := a5.CellToLonLat(cellID)
fmt.Printf("Center: %v\n", center)
// Get the resolution of a cell
res := a5.GetResolution(cellID)
fmt.Printf("Resolution: %d\n", res)
// Navigate the hierarchy
parent, _ := a5.CellToParent(cellID, res-1)
children, _ := a5.CellToChildren(cellID, res+1)
fmt.Printf("Parent: %d, Children: %d\n", parent, len(children))
// Compact and uncompact cell sets
compacted := a5.Compact(children)
fmt.Printf("Compacted: %v\n", compacted)
}A5 uses a pentagonal tiling of a dodecahedron. The dodecahedron has the lowest vertex curvature of all the Platonic solids, making it the most spherical. This minimizes cell distortion when projecting onto the globe — the lower the original vertex curvature, the less warping is introduced by the projection.
Unlike other DGGSs (H3 uses hexagons, S2 uses squares, HTM uses triangles), A5 has a single cell topology with no mixed cell shapes.
- 31 resolution levels from whole-world to sub-centimeter precision
- Equal-area cells at each resolution level, preventing spatial bias
- 64-bit integer cell IDs with Hilbert curve ordering for spatial locality
- Single cell topology — only pentagons, no mixed shapes
- Zero dependencies — pure Go implementation
LonLatToCell(lonLat, resolution)— geographic coordinates to cell IDCellToLonLat(cellID)— cell ID to center coordinates
GetResolution(cellID)— get the resolution level of a cellCellToParent(cellID, parentRes)— get the parent cell at a lower resolutionCellToChildren(cellID, childRes)— get child cells at a higher resolution
Compact(cells)— merge complete sibling groups into parent cellsUncompact(cells, targetRes)— expand cells to a target resolution
Serialize(cell)— encode an A5Cell to a uint64Deserialize(cellID)— decode a uint64 to an A5Cell