Hierarchy functions in the A5 Geospatial Index DuckDB extension
Function category
Hierarchy
5 functionsNavigate up and down A5's 31-level resolution hierarchy. Roll cells up to a coarser parent for aggregation, expand to children for fine-grained analysis, or compact a set of sibling cells back into their parent.
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
child_resolution
|
Type
INTEGER
|
Mode Positional | Description |
Description
Returns the immediate child A5 cells (one resolution finer)
1
Example 1
SELECT a5_cell_to_children(a5_lonlat_to_cell(-122.4, 37.8, 5));
Output
| a5_cell_to_children(a5_lonlat_to_cell(-122.4, 37.8, 5)) |
|---|
| [1936688577257668608, 1936970052234379264, 1937251527211089920, 1937533002187800576] |
Related functions
Signature
a5_cell_to_parent(cell: UBIGINT, parent_resolution: INTEGER) → UBIGINT
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
cell
|
Type
UBIGINT
|
Mode Positional | Description |
Argument
parent_resolution
|
Type
INTEGER
|
Mode Positional | Description |
Description
Returns the parent A5 cell at the specified coarser resolution
1
Example 1
SELECT a5_cell_to_parent(a5_lonlat_to_cell(-122.4, 37.8, 10), 5);
Output
| a5_cell_to_parent(a5_lonlat_to_cell(-122.4, 37.8, 10), 5) |
|---|
| 1937110789722734592 |
Related functions
- a5_cell_to_children() — Returns the immediate child A5 cells (one resolution finer)
- a5_get_num_children() — Returns the number of child cells at child_resolution that fit within a cell at parent_resolution
- a5_compact() — Compacts a list of A5 cells by merging complete sets of sibling cells into parent cells
Signature
a5_compact(cells: UBIGINT[]) → UBIGINT[]
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
cells
|
Type
UBIGINT[]
|
Mode Positional | Description |
Description
Compacts a list of A5 cells by merging complete sets of sibling cells into parent cells
1
Example 1
SELECT a5_compact(a5_cell_to_children(a5_lonlat_to_cell(-122.4, 37.8, 5)));
Output
| a5_compact(a5_cell_to_children(a5_lonlat_to_cell(-122.4, 37.8, 5))) |
|---|
| [1937110789722734592] |
Signature
a5_get_num_children(parent_resolution: INTEGER, child_resolution: INTEGER) → UBIGINT
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
parent_resolution
|
Type
INTEGER
|
Mode Positional | Description |
Argument
child_resolution
|
Type
INTEGER
|
Mode Positional | Description |
Description
Returns the number of child cells at child_resolution that fit within a cell at parent_resolution
1
Example 1
SELECT a5_get_num_children(0, 1);
Output
| a5_get_num_children(0, 1) |
|---|
| 5 |
Signature
a5_uncompact(cells: UBIGINT[], target_resolution: INTEGER) → UBIGINT[]
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
cells
|
Type
UBIGINT[]
|
Mode Positional | Description |
Argument
target_resolution
|
Type
INTEGER
|
Mode Positional | Description |
Description
Expands a compacted list of A5 cells to the specified target resolution
1
Example 1
SELECT a5_uncompact([a5_lonlat_to_cell(-122.4, 37.8, 5)], 7);
Output
| a5_uncompact(main.list_value(a5_lonlat_to_cell(-122.4, 37.8, 5)), 7) |
|---|
| [1936583024141402112, 1936653392885579776, 1936723761629757440, 1936794130373935104, 1936864499118112768, 1936934867862290432, 1937005236606468096, 1937075605350645760, 1937145974094823424, 1937216342839001088, 1937286711583178752, 1937357080327356416, 1937427449071534080, 1937497817815711744, 1937568186559889408, 1937638555304067072] |