Skip to content

Hierarchy functions in the A5 Geospatial Index DuckDB extension

Function category

Hierarchy

5 functions

Navigate 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.

a5_cell_to_children

Scalar function Hierarchy
Signature
2 overloaded forms · click to inspect
Arguments (Positional)
Argument cell Type UBIGINT Mode Positional Description
Description
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]

a5_cell_to_parent

Scalar function Hierarchy
Signature
a5_cell_to_parent(cell: UBIGINT, parent_resolution: INTEGER) UBIGINT
Arguments (Positional)
Argument cell Type UBIGINT Mode Positional Description
Argument parent_resolution Type INTEGER Mode Positional Description
Description
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

a5_compact

Scalar function Hierarchy
Signature
a5_compact(cells: UBIGINT[]) UBIGINT[]
Arguments (Positional)
Argument cells Type UBIGINT[] Mode Positional Description
Description
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]

a5_get_num_children

Scalar function Hierarchy
Signature
a5_get_num_children(parent_resolution: INTEGER, child_resolution: INTEGER) UBIGINT
Arguments (Positional)
Argument parent_resolution Type INTEGER Mode Positional Description
Argument child_resolution Type INTEGER Mode Positional Description
Description
1 Example 1
SELECT a5_get_num_children(0, 1);

Output

a5_get_num_children(0, 1)
5

a5_uncompact

Scalar function Hierarchy
Signature
a5_uncompact(cells: UBIGINT[], target_resolution: INTEGER) UBIGINT[]
Arguments (Positional)
Argument cells Type UBIGINT[] Mode Positional Description
Argument target_resolution Type INTEGER Mode Positional Description
Description
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]