| a5_cell_from_arrow | R Documentation |
Losslessly convert between a5_cell vectors and Arrow uint64
arrays. This avoids the precision loss that occurs when Arrow
converts uint64 to R's double (which can only represent
integers exactly up to 2^53, while A5 cell IDs span the full
0–2^64 range).
a5_cell_from_arrow(x)
a5_cell_to_arrow(x)
x |
For |
Internally these use Arrow's zero-copy View() to reinterpret
uint64 bytes as fixed_size_binary(8), then convert to/from the
raw-byte representation used by a5_cell. The resulting Arrow
arrays can be written directly to Parquet and read correctly by
DuckDB, Python, and other Arrow-compatible tools.
a5_cell_from_arrow() returns an a5_cell vector.
a5_cell_to_arrow() returns an Arrow Array of type uint64.
a5_u64_to_hex() for converting to hex strings instead.
cell <- a5_lonlat_to_cell(135, 0, resolution = 10)
arr <- a5_cell_to_arrow(cell)
back <- a5_cell_from_arrow(arr)
identical(format(cell), format(back))
cells <- a5_lonlat_to_cell(c(-3.19, 135), c(55.95, 0), resolution = 10)
arr <- a5_cell_to_arrow(cells)
arr$type$ToString()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.