Learn R Programming

raster (version 1.8-3)

mask: Mask values in a Raster object

Description

Create a new Raster* object where all cells that are NA in a 'mask' object are set to NA, and that has the same values as x in the other cells.

Usage

mask(x, mask, ...)

Arguments

x
A Raster* object
mask
A Raster* object
...
Additional arguments. See below, under Methods

Value

  • A new Raster* object, and in some cases the side effect of a new file on disk.

Methods

The following additional arguments can be passed, to replace default values for this function rll{ 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) }

Examples

Run this code
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