Mask values in a SpatRaster
Create a new SpatRaster that has the same values as SpatRaster x
, except for the cells that are NA
(or another maskvalue
) in another SpatRaster (the 'mask'), or not covered by a SpatVector. These cells become NA
(or another updatevalue
).
## S4 method for signature 'SpatRaster,SpatRaster' mask(x, mask, inverse=FALSE, maskvalues=NA, updatevalue=NA, filename="", ...) ## S4 method for signature 'SpatRaster,SpatVector' mask(x, mask, inverse=FALSE, updatevalue=NA, touches=TRUE, filename="", ...)
x |
SpatRaster |
mask |
SpatRaster |
inverse |
logical. If |
maskvalues |
numeric. The value(s) in |
updatevalue |
numeric. The value that cells of |
touches |
logical. If |
filename |
character. Output filename |
... |
additional arguments for writing files as in |
SpatRaster
r <- rast(ncol=10, nrow=10) m <- rast(ncol=10, nrow=10) values(r) <- 1:100 set.seed(1965) x <- round(3 * runif(ncell(r))) x[x==0] <- NA values(m) <- x mr <- mask(r, m)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.