| a5_hierarchy | R Documentation |
a5_cell_to_parent() returns the ancestor of each cell at a coarser
resolution. a5_cell_to_children() returns the descendants of each cell
at a finer resolution: 4 per resolution step, or 5 from resolution 0.
Both follow the cell index, so they are cheap bit operations.
a5_cell_to_parent(cell, parent_resolution = NULL, resolution)
a5_cell_to_children(cell, child_resolution = NULL, simplify = TRUE, resolution)
cell |
An a5_cell vector. |
parent_resolution |
Integer scalar target resolution for
|
resolution |
Deprecated: renamed |
child_resolution |
Integer scalar target resolution for
|
simplify |
Logical scalar. If |
a5_cell_to_parent(): an a5_cell vector the same length as cell.
a5_cell_to_children(): an a5_cell vector, or an a5_cell_list when
simplify = FALSE. An NA input contributes no cells (an empty element
in the list form).
A5 parents and children are defined by the cell index, not by geometry. A cell's index children do not tile it: their union overlaps the parent's neighbours. Measured over random cells, the index parent is not the coarse cell containing a fine cell's centre for about half of fine cells one resolution apart, falling to about 35 percent at four or more resolutions apart. Use these functions for operations on ids (compaction, id ranges, curve ordering) and a5_spatial_hierarchy when cells must nest by location.
a5_spatial_hierarchy for parents and children by location,
a5_cell_child() for one child at a time, a5_cell_children_range()
for the id range of all descendants, a5_get_resolution().
cell <- a5_lonlat_to_cell(-3.19, 55.95, resolution = 10)
a5_cell_to_parent(cell)
a5_cell_to_parent(cell, parent_resolution = 5)
a5_cell_to_children(cell)
cells <- a5_lonlat_to_cell(c(-3.19, 0), c(55.95, 0), resolution = 5)
a5_cell_to_children(cells, child_resolution = 7) # 32 cells
a5_cell_to_children(cells, child_resolution = 7, simplify = FALSE) # list of 2
# children map back to their parent
all(a5_cell_to_parent(a5_cell_to_children(cell, 12), 10) == cell)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.