rMask: Select cells of a raster based on a mask

Description Usage Arguments Details Value See Also Examples

View source: R/modify.operators.R

Description

Select cells of a raster based on a mask

Usage

1
rMask(obj, mask = NULL, background = NULL)

Arguments

obj

[RasterLayer(1)]
The object to modify.

mask

[RasterLayer(1) | matrix(1) | geom(1)]
Either binary object of the same dimension as obj where the cells that should be retained have the value 1 and all other cells the value 0 or
geom where values inside the geom should be retained.

background

[integerish(1)]
the value any cell with value NA should have.

Details

If used in an algorithm, mask can also contain the name of a sub-algorithm to use the final output thereof as mask. Moreover, mask = "input" would select the original raster as mask.

Value

A RasterLayer of the same dimensions as obj, in which all cells with value 0 in the mask have been set to NA and all other values are retained.

See Also

Other operators to select a subset of cells: rBounded, rGreater, rLess, rMatch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
input <- rtRasters$continuous
m <- matrix(nrow = 56, ncol = 60, data = 0)
m[c(5:25), c(5:50)] <- 1

visualise(rMask(input, mask = m))

## Not run: 

# determine mask interactively
mask <- geomPolygon(template = input, vertices = 5, show = T, col = "deeppink")
mask <- gToRaster(mask)

visualise(raster = rMask(obj = input, mask = mask))

## End(Not run)

EhrmannS/rasterTools documentation built on Sept. 4, 2019, 10:34 a.m.