Skip to contents

Creates a mask where a cell in any layer of r that is NA will be returned as NA.

Usage

mask_from_all(r)

Arguments

r

SpatRaster with >1 layer.

Value

SpatRaster with values NA or 1.

Details

Similar in intention to mask_all, but (a) will work on larger rasters because it only holds the values of a single layer in memory at a time, and (b) returns a mask layer, rather than masking each layer in r. Can be very slow

Examples

r <- example_raster(seed = 10)
s <- example_raster(seed = 11)

r[10:20] <- NA

s[5:15] <- NA

q <- mask_from_all(c(r,s))

library("terra")
plot(c(r,s,q))