| a5_set_operations | R Documentation |
Set operations on a5_covering vectors, computed on the compacted cells without expanding them, so they stay fast for coverings that stand for billions of cells:
a5_union(x, y = NULL)
a5_intersect(x, y)
a5_difference(x, y)
x, y |
a5_covering vectors, or objects |
a5_union(): cells in either covering. With y omitted, the union of
every covering in x, as one covering: for example the coverings of all
features from a5_polygon_to_cells().
a5_intersect(): cells in both coverings.
a5_difference(): cells in x but not in y.
The operations work element by element, recycling a length-one argument,
so a5_intersect(countries, cap) intersects every country with one cap.
Both coverings of a pair must be at the same resolution: A5 cells do not
nest geometrically across resolutions, so combining sets at different
resolutions has no meaning, and it is an error. An empty covering with no
recorded resolution, as a5_compact() returns for no cells, combines with
any covering as the empty set.
An a5_covering vector of the common size of x and y (size
one for a5_union(x)). NA where either input is NA; a5_union(x)
skips NA elements.
a5_contains(), a5_overlaps() and a5_count() to query
coverings.
edinburgh <- a5_lonlat_to_cell(-3.19, 55.95, resolution = 12)
glasgow <- a5_lonlat_to_cell(-4.25, 55.86, resolution = 12)
caps <- a5_spherical_cap(c(edinburgh, glasgow), radius = 40000)
a5_union(caps[1], caps[2])
a5_intersect(caps[1], caps[2])
a5_difference(caps[1], caps[2])
# the union of every element
a5_union(caps)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.