rBlend: Blend two rasters with each other

Description Usage Arguments Details Value See Also Examples

View source: R/modify.operators.R

Description

Blend two rasters simply by adding (and weighing) their values per cell.

Usage

1
rBlend(obj, overlay, patches = FALSE, weight = 1)

Arguments

obj

[RasterLayer(1)]
The object to modify.

overlay

[RasterLayer(1) | matrix(1)]
the raster that should be blended with the primary raster (obj); has to have the same dimension as the primary raster.

patches

[logical(1)]
should the blend be carried out while considering foreground patches in the primary raster (TRUE), or should the blend be carried out without this consideration (FALSE, default).

weight

[numeric(1)]
the weight the overlay raster should have as multiple (or fraction) of the primary raster.

Details

In case patches = TRUE, the cells in the overlay are grouped according to the foreground patches in the primary raster and all cells of this group are assigned their common average, then the blend is carried out.

A blend operation currently is defined as 'overlay*weight + obj'. To aggregate more than two RasterLayers with arbitrary functions, see rReduce.

Value

A RasterLayer of the same dimension as primary, in which an overlay has been blended with the primary raster.

See Also

Other operators to modify a raster: rReduce, rRescale, rSegregate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# define primary raster ...
input <- rtRasters$continuous
patches <- rPatches(rBinarise(input, thresh = 30))

# ... and an overlay from a matrix
m <- matrix(nrow = 56, ncol = 60, data = 0)
m[c(5:25), c(5:50)] <- 10
mask <- raster::raster(m, xmn=0, xmx=60, ymn=0, ymx=56, crs=NA)

# blend while considering patches in the primary raster
blended <- rBlend(patches, overlay = mask, patches = TRUE)
visualise(raster::stack(patches, blended))

# blend while not considering patches
visualise(rBlend(patches, overlay = mask, weight = 10))

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