Coordinate Conversion functions in the A5 Geospatial Index DuckDB extension
Function category
Coordinate Conversion
4 functionsTranslate between geographic coordinates (longitude/latitude) and A5 cell IDs in their numeric or hex string forms. Use these as your entry and exit points for indexing data into A5.
Signature
a5_cell_to_lonlat(cell: UBIGINT) → DOUBLE[2]
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
cell
|
Type
UBIGINT
|
Mode Positional | Description |
Description
Returns the center point [longitude, latitude] of an A5 cell
1
Example 1
SELECT a5_cell_to_lonlat(a5_lonlat_to_cell(-122.4, 37.8, 10));
Output
| a5_cell_to_lonlat(a5_lonlat_to_cell(-122.4, 37.8, 10)) |
|---|
| (-122.37432272230853, 37.78289994807169) |
Related functions
Signature
a5_hex_to_u64(hex: VARCHAR) → UBIGINT
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
hex
|
Type
VARCHAR
|
Mode Positional | Description |
Description
Converts an A5 hex string representation to a UBIGINT cell ID
1
Example 1
SELECT a5_hex_to_u64('1600000000000000');
Output
| a5_hex_to_u64('1600000000000000') |
|---|
| 1585267068834414592 |
Signature
a5_lonlat_to_cell(
longitude: DOUBLE,
latitude: DOUBLE,
resolution: INTEGER
) → UBIGINT
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
longitude
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
latitude
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
resolution
|
Type
INTEGER
|
Mode Positional | Description |
Description
Converts a longitude/latitude coordinate to an A5 cell at the specified resolution
1
Example 1
SELECT a5_lonlat_to_cell(-122.4194, 37.7749, 10);
Output
| a5_lonlat_to_cell(-122.4194, 37.7749, 10) |
|---|
| 1937278465245970432 |
Signature
a5_u64_to_hex(cell: UBIGINT) → VARCHAR
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
cell
|
Type
UBIGINT
|
Mode Positional | Description |
Description
Converts a UBIGINT A5 cell ID to its hex string representation
1
Example 1
SELECT a5_u64_to_hex(a5_lonlat_to_cell(-122.4, 37.8, 10));
Output
| a5_u64_to_hex(a5_lonlat_to_cell(-122.4, 37.8, 10)) |
|---|
| 1ae2988000000000 |