nh_stack_resample: Aggregate values from a nh_stack to a lower (coarser)...

View source: R/nh_stack.R

nh_stack_resampleR Documentation

Aggregate values from a nh_stack to a lower (coarser) resolution raster, or within polygons

Description

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).

Usage

nh_stack_resample(rast, lookup, fact = 10, spf = NULL)

Arguments

rast

raster output from nh_stack

lookup

lookup table from nh_stack

fact

aggregation factor, in number of cells (see ?terra::aggregate)

spf

Optional vector spatial features to use for aggregation (sp or sf-class polygons). If supplied, fact will be ignored

Details

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.

Value

SpatRaster or spf (with attributes added)

Author(s)

David Bucklin

Examples

## 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)

VANatHeritage/nhSDM documentation built on Feb. 1, 2024, 6:39 a.m.