a5_cell_child: The i-th child of each cell

View source: R/hierarchy.R

a5_cell_childR Documentation

The i-th child of each cell

Description

Returns one descendant of each cell at a finer resolution without enumerating the others: the i-th element of what a5_cell_to_children() would return. Useful for random draws from large cells, where building the full child list to pick one element is wasteful.

Usage

a5_cell_child(cell, child_resolution, i)

Arguments

cell

An a5_cell vector.

child_resolution

Integer scalar target resolution, at or finer than every cell's own resolution.

i

Integer vector of 1-based child positions, recycled against cell. Must lie within 1:a5_get_num_children(res, child_resolution) for each cell's resolution res; out of range is an error.

Value

An a5_cell vector the same length as cell. NA where cell or i is NA.

See Also

a5_cell_to_children(), a5_get_num_children()

Examples

cell <- a5_lonlat_to_cell(-3.19, 55.95, resolution = 5)
a5_cell_child(cell, child_resolution = 7, i = 1:16)
identical(a5_cell_child(cell, 7, 1:16), a5_cell_to_children(cell, 7))

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