Search Shortcut cmd + k | ctrl + k

Hierarchical pentagonial indexing for geospatial data that is equal-area and millimeter accurate.

Maintainer(s): rustyconover

Compatibility Matrix

This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.

Platform 1.4.4 1.4.5 1.5.5 1.5.6 2.0.0
Linux AMD64
Linux ARM64
macOS AMD64
macOS ARM64
Windows AMD64
Windows ARM64
WebAssembly

Installing and Loading

INSTALL a5 FROM community;
LOAD a5;

About a5

For more information regarding usage, see the documentation.

Added Functions

function_name function_type description comment examples
a5_area scalar Returns the total area in square meters of a list of A5 cells (compacted or not). Overlapping cells each add their area - use a5_union to merge them first NULL [a5_area(a5_spherical_cap(a5_lonlat_to_cell(-122.4, 37.8, 10), 5000.0))]
a5_cell_area scalar Returns the area in square meters of an A5 cell at the specified resolution level (-1 gives the world cell, i.e. the whole globe) NULL [a5_cell_area(10)]
a5_cell_edge_length_avg scalar Returns the average edge length in meters of an A5 cell at the specified resolution level; individual edges vary from the average by roughly +/-10% NULL [a5_cell_edge_length_avg(10)]
a5_cell_to_boundary scalar Returns the boundary vertices of an A5 cell as a closed ring of [lon, lat] points NULL [a5_cell_to_boundary(a5_lonlat_to_cell(-122.4, 37.8, 5))]
a5_cell_to_boundary scalar Returns the boundary vertices of an A5 cell with configurable ring closure and edge interpolation segments NULL [a5_cell_to_boundary(a5_lonlat_to_cell(-122.4, 37.8, 5), true, 4)]
a5_cell_to_boundary scalar Returns the boundary vertices of an A5 cell, optionally as an open or closed ring NULL [a5_cell_to_boundary(a5_lonlat_to_cell(-122.4, 37.8, 5), false)]
a5_cell_to_children scalar Returns all child A5 cells at the specified finer resolution NULL [a5_cell_to_children(a5_lonlat_to_cell(-122.4, 37.8, 5), 6)]
a5_cell_to_children scalar Returns the immediate child A5 cells (one resolution finer) NULL [a5_cell_to_children(a5_lonlat_to_cell(-122.4, 37.8, 5))]
a5_cell_to_geometry scalar Returns an A5 cell as a POLYGON geometry of its boundary NULL [a5_cell_to_geometry(a5_lonlat_to_cell(-122.4, 37.8, 5))]
a5_cell_to_geometry scalar Returns an A5 cell as a POLYGON geometry, with each edge interpolated into the given number of segments NULL [a5_cell_to_geometry(a5_lonlat_to_cell(-122.4, 37.8, 5), 4)]
a5_cell_to_lonlat scalar Returns the center point [longitude, latitude] of an A5 cell NULL [a5_cell_to_lonlat(a5_lonlat_to_cell(-122.4, 37.8, 10))]
a5_cell_to_parent scalar Returns the immediate parent A5 cell (one resolution coarser) NULL [a5_cell_to_parent(a5_lonlat_to_cell(-122.4, 37.8, 10))]
a5_cell_to_parent scalar Returns the parent A5 cell at the specified coarser resolution (-1 gives the world cell) NULL [a5_cell_to_parent(a5_lonlat_to_cell(-122.4, 37.8, 10), 5)]
a5_cell_to_point scalar Returns the center of an A5 cell as a POINT geometry NULL [a5_cell_to_point(a5_lonlat_to_cell(-122.4, 37.8, 5))]
a5_cell_to_subcells scalar Returns the A5 cells at the specified finer resolution whose centers lie in the cell: the spatial counterpart of a5_cell_to_children and the inverse of a5_cell_to_supercell. The result is a covering: compacted cells sorted in curve order, followed by a compaction marker recording the resolution - use a5_uncompact to expand it NULL [a5_cell_to_subcells(a5_lonlat_to_cell(-122.4, 37.8, 5), 8)]
a5_cell_to_supercell scalar Returns the A5 cell at the specified coarser resolution that contains the center of the cell: the spatial counterpart of a5_cell_to_parent, whose result need not contain the cell (-1 gives the world cell) NULL [a5_cell_to_supercell(a5_lonlat_to_cell(-122.4, 37.8, 10), 5)]
a5_compact scalar Compacts a list of A5 cells by merging complete sets of sibling cells into parent cells. The result is a covering: compacted cells sorted in curve order, followed by a compaction marker recording the resolution - use a5_uncompact to expand it NULL [a5_compact(a5_cell_to_children(a5_lonlat_to_cell(-122.4, 37.8, 5)))]
a5_contains scalar Returns true if the cell is in the list of A5 cells (compacted or not). The cell must be at the resolution of the list, and the list must be sorted in curve order, as coverings are NULL [a5_contains(a5_spherical_cap(a5_lonlat_to_cell(-122.4, 37.8, 10), 5000.0), a5_lonlat_to_cell(-122.4, 37.8, 10))]
a5_count scalar Returns the number of cells in a list of A5 cells at its resolution, i.e. the length of the uncompacted list. Overlapping cells are counted more than once - use a5_union to merge them first NULL [a5_count(a5_spherical_cap(a5_lonlat_to_cell(-122.4, 37.8, 10), 5000.0))]
a5_covering_resolution scalar Returns the resolution of a list of A5 cells: the resolution of its compaction marker, or of its finest cell when it has none. Returns -1 for an empty list NULL [a5_covering_resolution(a5_grid_disk(a5_lonlat_to_cell(-122.4, 37.8, 10), 2))]
a5_difference scalar Returns the difference of two lists of A5 cells: the cells in a but not in b. Both lists must be at the same resolution. The result is a covering: compacted cells sorted in curve order, followed by a compaction marker recording the resolution - use a5_uncompact to expand it NULL [a5_difference(a5_grid_disk(a5_lonlat_to_cell(-122.4, 37.8, 10), 2), a5_spherical_cap(a5_lonlat_to_cell(-122.4, 37.8, 10), 5000.0))]
a5_geometry_to_cells scalar Returns the A5 cells covering an arbitrary geometry at the given resolution, as above. For polygon parts, setting overlapping to true additionally includes every cell that touches the polygon boundary, giving gap-free coverage instead of the default cell-center containment NULL [a5_geometry_to_cells('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))'::GEOMETRY, 8, true)]
a5_geometry_to_cells scalar Returns the A5 cells covering an arbitrary geometry at the given resolution. Points map to their containing cell, lines are traced, and polygons are filled with cell-center containment (holes excluded); MULTI* and GEOMETRYCOLLECTION inputs are unioned. A geometry with polygon parts gives a covering: compacted cells sorted in curve order, followed by a compaction marker recording the resolution - use a5_uncompact to expand it. Other geometries give their cells at the resolution, in geometry order NULL [a5_geometry_to_cells('MULTIPOINT((0 0), (10 10))'::GEOMETRY, 8)]
a5_get_num_cells scalar Returns the total number of A5 cells at the specified resolution level (0-30) NULL [a5_get_num_cells(5)]
a5_get_num_children scalar Returns the number of child cells at child_resolution that fit within a cell at parent_resolution (-1 for the world cell) NULL [a5_get_num_children(0, 1)]
a5_get_res0_cells scalar Returns all 12 resolution 0 (root) A5 cells covering the entire globe NULL [a5_get_res0_cells()]
a5_get_resolution scalar Returns the resolution level (0-30) of an A5 cell NULL [a5_get_resolution(a5_lonlat_to_cell(-122.4, 37.8, 10))]
a5_grid_disk scalar Returns all A5 cells within k edge-steps of the given cell (edge adjacency), as a covering: compacted cells sorted in curve order, followed by a compaction marker recording the resolution - use a5_uncompact to expand it NULL [a5_grid_disk(a5_lonlat_to_cell(-122.4, 37.8, 10), 1)]
a5_grid_disk_vertex scalar Returns all A5 cells within k vertex-steps of the given cell (vertex adjacency), as a covering: compacted cells sorted in curve order, followed by a compaction marker recording the resolution - use a5_uncompact to expand it NULL [a5_grid_disk_vertex(a5_lonlat_to_cell(-122.4, 37.8, 10), 1)]
a5_hex_to_u64 scalar Converts an A5 hex string representation to a UBIGINT cell ID NULL [a5_hex_to_u64('1600000000000000')]
a5_intersect scalar Returns the intersection of two lists of A5 cells: the cells in both. Both lists must be at the same resolution. The result is a covering: compacted cells sorted in curve order, followed by a compaction marker recording the resolution - use a5_uncompact to expand it NULL [a5_intersect(a5_grid_disk(a5_lonlat_to_cell(-122.4, 37.8, 10), 2), a5_spherical_cap(a5_lonlat_to_cell(-122.4, 37.8, 10), 5000.0))]
a5_is_compaction_marker scalar Returns true if the value is a compaction marker: the last element of a covering (as returned by a5_compact, a5_grid_disk, a5_spherical_cap, a5_cell_to_subcells, polygon coverings and the set operations), recording the resolution its cells stand for. A compaction marker is not a cell NULL [list_filter(a5_grid_disk(a5_lonlat_to_cell(-122.4, 37.8, 10), 1), x -> NOT a5_is_compaction_marker(x))]
a5_is_valid_cell scalar Returns true if the value is a valid A5 cell ID (a canonically-encoded cell). The world cell (0) is considered valid NULL [a5_is_valid_cell(a5_lonlat_to_cell(-122.4, 37.8, 5))]
a5_lonlat_to_cell scalar Converts a longitude/latitude coordinate to an A5 cell at the specified resolution NULL [a5_lonlat_to_cell(-122.4194, 37.7749, 10)]
a5_max_resolution scalar Returns the finest A5 resolution level (30). Resolutions run from 0 to this value NULL [a5_max_resolution()]
a5_migrate scalar Migrates an A5 cell ID created by a pre-1.0 version of A5 (a5 crate <= 0.10) to the ID of the same cell in the current index. Cell IDs changed in A5 1.0, so stored cell IDs must be migrated once NULL [a5_migrate(2742821848331845632)]
a5_overlaps scalar Returns true if two lists of A5 cells (compacted or not) share any cell. Both lists must be at the same resolution NULL [a5_overlaps(a5_grid_disk(a5_lonlat_to_cell(-122.4, 37.8, 10), 2), a5_spherical_cap(a5_lonlat_to_cell(-122.4, 37.8, 10), 5000.0))]
a5_spherical_cap scalar Returns all A5 cells within the specified radius (in meters) of the given cell, as a covering: compacted cells sorted in curve order, followed by a compaction marker recording the resolution - use a5_uncompact to expand it NULL [a5_spherical_cap(a5_lonlat_to_cell(-122.4, 37.8, 10), 1000.0)]
a5_u64_to_hex scalar Converts a UBIGINT A5 cell ID to its hex string representation NULL [a5_u64_to_hex(a5_lonlat_to_cell(-122.4, 37.8, 10))]
a5_uncompact scalar Expands a list of A5 cells to all their cells at the resolution of the list: the resolution of its compaction marker, or of its finest cell when it has none. The compaction marker is dropped from the result NULL [a5_uncompact(a5_grid_disk(a5_lonlat_to_cell(-122.4, 37.8, 10), 2))]
a5_union scalar Returns the union of two lists of A5 cells: the cells in either. Both lists must be at the same resolution. The result is a covering: compacted cells sorted in curve order, followed by a compaction marker recording the resolution - use a5_uncompact to expand it NULL [a5_union(a5_grid_disk(a5_lonlat_to_cell(-122.4, 37.8, 10), 2), a5_spherical_cap(a5_lonlat_to_cell(-122.4, 37.8, 10), 5000.0))]
a5_world_cell scalar Returns the A5 world cell, the root cell that covers the entire globe and is the ancestor of all resolution-0 cells NULL [a5_world_cell()]

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

This extension does not add any settings.