NA
in a 'mask' object are set to NA
, and that has the same values as x
in the other cells. Or use inverse=TRUE
to set the cells that are not NA
in the mask to NA
.mask(x, mask, ...)
reverse
Boolean. If TRUE
, areas on mask
that are _not_ NA are masked.
filename
Character. output filename
format
Character. Output file type. See writeRaster
datatype
Character. Output data type. See dataType
overwrite
Logical. If TRUE
, "filename" will be overwritten if it exists
progress
Character. "text", "window", or "" (the default, no progress bar)
}r <- raster(ncol=10, nrow=10)
m <- raster(ncol=10, nrow=10)
r[] <- runif(ncell(r)) * 10
m[] <- runif(ncell(r))
m[m <0.5] <- NA
mr <- mask(r, m)
Run the code above in your browser using DataLab