Returns A5 cells at resolution whose centres fall inside the polygon.
Multi-feature inputs (a MULTIPOLYGON, an sfc of multiple polygons,
or a POLYGON with holes) are handled natively: per polygon part, the
outer-ring cells are computed and any hole-ring cells are subtracted,
then the results are unioned across parts. The final cell set is
compacted; use a5_uncompact() to expand to a uniform-resolution grid.
Arguments
- x
A polygon-like geometry. One of:
Any geometry handleable by
wk::wk_handle()(e.g.wk::wkt(),wk::wkb(),wk::rct(),sf,sfc) containing one or morePOLYGON/MULTIPOLYGONfeatures.A
SpatVectorof polygons (requires theterrapackage).A two-column numeric matrix (
cbind(lon, lat)) of vertices, interpreted as a single outer ring.A
data.framewith columnslonandlat, interpreted as a single outer ring.
- resolution
Integer scalar target resolution (0-30).
Value
An a5_cell vector at or coarser than resolution.
Details
Membership is determined by centre-point containment: a cell is
included iff its centroid lies inside the polygon, with hole rings
properly subtracted. This is distinct from a5_grid()'s
boundary-intersection semantics; for the same polygon the two
functions can return slightly different cell sets near the boundary.
Coordinates must be WGS 84 longitude/latitude in degrees. Rings are closed automatically; a trailing duplicate vertex is dropped if present.
Where no A5 cell centroids at the specified resolution fall within
the geometry, an empty a5_cell vector is returned.
Matrix and data.frame inputs are treated as a single ring; for
multi-feature data or polygons with holes, pass an sf, sfc, wk,
or SpatVector geometry instead.
