lotsOfMasks: Generate and apply multiple masks to a map

Description Usage Arguments Details Value Author(s) Examples

View source: R/mask.R

Description

Based on a potential distribution, environmental rasters, and bounds for suitable habitat on the environmental rasters

Usage

1
lotsOfMasks(expertRaster, maskStack, maskBounds)

Arguments

expertRaster

The binary expert map (1s and 0s), rasterized with the same projection as 'maskStack'

maskStack

A stack of *named* layers from which masks will be made

maskBounds

A data.frame with columns indicating the layer name (matching the names in maskStack), and the min and max values of that layer to be used for masking.

Details

See Examples.

Value

a RasterStack

Author(s)

Cory Merow <cory.merow@gmail.com>,

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
r1 <- raster::raster(nrows=108, ncols=21, xmn=0, xmx=10)
raster::values(r1)<- sort(runif(n = (108*21)))
r1[r1>0.5] <- 1
r1[r1<0.5] <- 0
r2 <- raster::raster(nrows=108, ncols=21, xmn=0, xmx=10)
raster::values(r2) <- runif(n=(108*21))
r3 <- raster::raster(nrows=108, ncols=21, xmn=0, xmx=10)
raster::values(r3) <- runif(n=(108*21))
maskStack <- raster::stack(r2, r3)
names(maskStack) <- c("r2", "r3")
minbounds <- c(0.3, 0.4)
maxbounds <- c(0.4, 0.5)
maskBounds <- data.frame(cbind(c("r2", "r3"), minbounds, maxbounds))
colnames(maskBounds)<- c("Layer", "Min Value", "Max Value")
maskBounds[,2] <- as.numeric(as.character(maskBounds[,2]))
maskBounds[,3] <- as.numeric(as.character(maskBounds[,3]))
out <- lotsOfMasks(expertRaster = r1, maskStack = maskStack, maskBounds = maskBounds)

maskRangeR documentation built on Nov. 10, 2021, 5:09 p.m.