
Apply an elevation suitability mask to a species projection
Source:R/create_elevation_mask.R
apply_elevation_mask.RdAlign an elevation suitability mask to a species projection and multiply the
species values by the mask. The output follows the class, geometry, layer
count, and temporal dimension of species_projection.
Arguments
- elevation_mask
A
terra::SpatRasterorstarsobject containing suitability weights in[0, 1], typically fromcreate_elevation_mask().- species_projection
A
terra::SpatRasterorstarsspecies projection to be masked.
Details
The mask is reprojected, cropped, and resampled to the species grid when
needed. Static masks are repeated across temporal species projections. When
both inputs are same-class temporal objects, mask time steps are aligned to
the species projection with align_temporal().
Examples
require(terra)
species <- terra::rast(nrow = 1, ncol = 3, vals = c(0.2, 0.6, 1))
mask <- terra::rast(nrow = 1, ncol = 3, vals = c(0, 0.5, 1))
apply_elevation_mask(mask, species)
#> class : SpatRaster
#> size : 1, 3, 1 (nrow, ncol, nlyr)
#> resolution : 120, 180 (x, y)
#> extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (CRS84) (OGC:CRS84)
#> source(s) : memory
#> name : lyr.1
#> min value : 0
#> max value : 1