| a5_cell_children_range | R Documentation |
Returns the smallest and largest descendant of each cell at a finer
resolution, without enumerating the descendants. Because the A5 index
encodes position along a space-filling curve with a cell's descendants sharing
its leading bits, the descendants of a cell at any resolution up to 29
occupy a contiguous range of ids among all cells at that resolution: every
cell at child_resolution whose id lies between lo and hi inclusive is a
descendant, and no descendant lies outside. This makes BETWEEN lo AND hi
an exact filter on a store of child_resolution cells sorted by id. Not every
integer in the range is a valid cell, and cells of other resolutions may
fall inside it.
a5_cell_children_range(cell, child_resolution)
cell |
An a5_cell vector. |
child_resolution |
Integer scalar target resolution from 0 to 29, at or finer than every cell's own resolution. |
Resolution 30 is refused because the guarantee does not hold there. The
index has no room for the usual face bits at that resolution, so faces use
three different bit layouts whose id ranges overlap numerically, and a
range can contain valid resolution-30 cells from another face. Eighteen of
the sixty faces cannot be encoded at resolution 30 at all; the upstream
library falls back to resolution 29 for them. Use
a5_cell_to_children() if you need resolution-30 descendants.
A data frame with a5_cell columns lo and hi, one row per
input cell. NA where cell is NA.
a5_cell_to_children(), a5_cell_to_arrow() for exact 64-bit
ids to pass to SQL.
cell <- a5_lonlat_to_cell(-3.19, 55.95, resolution = 5)
rng <- a5_cell_children_range(cell, child_resolution = 8)
children <- vctrs::vec_sort(a5_cell_to_children(cell, child_resolution = 8))
identical(rng$lo, children[1])
identical(rng$hi, children[length(children)])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.