Geometry Integration functions in the A5 Geospatial Index DuckDB extension
Function category
Geometry Integration
3 functionsConvert cells to and from DuckDB's built-in GEOMETRY type — no spatial extension dependency required to produce it. Turn a cell into its boundary polygon or center point, or cover an arbitrary point, line, or polygon geometry with cells.
Signature
2 overloaded forms · click to inspectArguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
cell
|
Type
UBIGINT
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
cell
|
Type
UBIGINT
|
Mode Positional | Description |
Argument
segments
|
Type
INTEGER
|
Mode Positional | Description |
Description
Returns an A5 cell as a POLYGON geometry of its boundary
SELECT a5_cell_to_geometry(a5_lonlat_to_cell(-122.4, 37.8, 5));
Output
| a5_cell_to_geometry(a5_lonlat_to_cell(-122.4, 37.8, 5)) |
|---|
| POLYGON ((-123.91841441068891 37.07072636323092, -123.07208493364055 36.93440251226853, -122.23003392974135 36.79239099498031, -121.39776711864215 36.97396218211518, -120.5617228138475 37.150588175283566, -120.90288444799262 37.727609112987, -121.24914021841249 38.30267874469804, -122.1294038096313 38.231723424706054, -123.00840835218185 38.15508109275352, -123.46729324681684 37.61361779528323, -123.91841441068891 37.07072636323092)) |
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
cell
|
Type
UBIGINT
|
Mode Positional | Description |
Description
Returns the center of an A5 cell as a POINT geometry
SELECT a5_cell_to_point(a5_lonlat_to_cell(-122.4, 37.8, 5));
Output
| a5_cell_to_point(a5_lonlat_to_cell(-122.4, 37.8, 5)) |
|---|
| POINT (-122.1945267557461 37.499947342760166) |
Signature
2 overloaded forms · click to inspectArguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
geom
|
Type
GEOMETRY
|
Mode Positional | Description |
Argument
resolution
|
Type
INTEGER
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
geom
|
Type
GEOMETRY
|
Mode Positional | Description |
Argument
resolution
|
Type
INTEGER
|
Mode Positional | Description |
Argument
overlapping
|
Type
BOOLEAN
|
Mode Positional | Description |
Description
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 by cell-center containment by default (holes excluded); MULTI* and GEOMETRYCOLLECTION inputs are unioned. The optional third overlapping argument additionally includes cells that merely touch the polygon boundary, for genuinely gap-free coverage. The result comes back compacted, which is the right shape for storage and set operations — but cell boundaries at different resolutions don't nest geometrically, so call a5_uncompact to a single resolution before drawing the covering as geometry (skip that and a mixed-resolution result will show phantom gaps that aren't really there).
SELECT a5_geometry_to_cells('MULTIPOINT((0 0), (10 10))'::GEOMETRY, 8);
Output
| a5_geometry_to_cells(CAST('MULTIPOINT((0 0), (10 10))' AS "GEOMETRY"), 8) |
|---|
| [5694194798391459840, 6240643281303109632] |