raster (version 1.1.7)

mosaic: mosaic RasterLayers

Description

Mosaic RasterLayers to form a new RasterLayer with a larger spatial extent applying a function to compute cell values in areas where layers overlap (in contrast to the merge function which uses the values of the 'upper' layer)

Usage

mosaic(x, y, ...)

Arguments

x
A RasterLayer object
y
A RasterLayer object
...
Additional RasterLayers and other arguments. See below, under Methods

Value

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

Details

The RasterLayer objects must have the same origin and resolution.

See Also

merge, expand

Examples

Run this code
r <- raster(ncol=100, nrow=100)
r1 <- crop(r, extent(-10, 11, -10, 11))
r2 <- crop(r, extent(0, 20, 0, 20))
r3 <- crop(r, extent(9, 30, 9, 30))

r1[] <- 1:ncell(r1)
r2[] <- 1:ncell(r2)
r3[] <- 1:ncell(r3)

m = mosaic(r1, r2, r3, fun=mean)

Run the code above in your browser using DataCamp Workspace