a5_cell_list: List of A5 cell vectors

a5_cell_listR Documentation

List of A5 cell vectors

Description

a5_cell_to_children(), a5_grid_disk() and a5_spherical_cap() return an a5_cell_list when called with simplify = FALSE: a vctrs::list_of() holding one a5_cell vector per input, usable as a list column. It behaves as any list: lengths() gives the number of cells per input, [[ extracts one element, and tidyr::unnest() expands it to one row per cell.

Usage

as_a5_cell_list(x)

## S3 method for class 'a5_cell_list'
unlist(x, recursive = TRUE, use.names = TRUE)

Arguments

x

An a5_cell_list, or for as_a5_cell_list() a list of a5_cell vectors.

recursive, use.names

Ignored.

Details

unlist() concatenates the elements into a single a5_cell vector, equivalent to vctrs::list_unchop(). Without this method base unlist() would descend into the raw byte fields of the record and return a meaningless raw vector. The recursive and use.names arguments are accepted for compatibility and ignored.

as_a5_cell_list() wraps a plain list of a5_cell vectors (for example the output of lapply()) so that unlist() works on it. Elements that are hex strings are converted; NULL elements become empty.

Value

unlist() returns an a5_cell vector.

Examples

cells <- a5_lonlat_to_cell(c(-3.19, 0), c(55.95, 0), resolution = 5)
lst <- a5_cell_to_children(cells, simplify = FALSE)
lengths(lst)
unlist(lst)

# lapply() produces a plain list, on which base unlist() would return raw
# bytes; wrap it first.
plain <- lapply(seq_along(cells), function(i) a5_cell_to_children(cells[i]))
unlist(as_a5_cell_list(plain))

a5R documentation built on Oct. 19, 2026, 5:08 p.m.