nh_stack_resample | R Documentation |
When, spf=NULL
, takes an output raster from nh_stack, and returns a lower-resolution
version, with recalculated species assemblages for the larger cells.
New values are "aggregated" by fact
, the number of cells
to aggregate in the x/y dimensions (see ?terra::aggregate
).
nh_stack_resample(rast, lookup, fact = 10, spf = NULL)
rast |
raster output from nh_stack |
lookup |
lookup table from nh_stack |
fact |
aggregation factor, in number of cells (see |
spf |
Optional vector spatial features to use for aggregation (sp or sf-class polygons). If supplied, |
Alternatively, you can aggregate species assemblages within polygons (sp or sf-class)
provided to spf
. Polygons intersecting areas with non-NA
cells in rast
are returned, with columns identifying species codes
and counts. Polygons will be returned in their original projection, but
processing internally is done in the raster's projection.
SpatRaster or spf (with attributes added)
David Bucklin
## Not run:
# stack <- nh_stack(list, rast, return.table = TRUE)
# resample from 30m to 990m resolution
stack1km <- nh_stack_resample(stack[[1]], stack[[2]], fact = 33)
# view raster attributes
cats(stack1km)
# view species count raster (index=3 is the 'ALLCODES_CT' column)
ct <- as.numeric(stack1km, index=3)
plot(ct)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.