Learn R Programming

raster (version 1.8-3)

merge: Merge RasterLayers

Description

Merge Raster* objects to form a new Raster object with a larger spatial extent.

Usage

merge(x, y, ...)

Arguments

x
A Raster* object
y
A Raster* object with the same number of layers as x
...
Additional Raster* objects and other arguments. See below, under Methods

Value

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

Details

The Raster objects must have the same origin and resolution. In areas where the Raster objects overlap, the values of the Raster object that is first in the sequence of arguments will be retained. If you'd rather use the average of cell values, or do another computation, you can use mosaic instead of merge.

See Also

mosaic, crop, expand

Examples

Run this code
r1 <- raster(xmx=-150, ymn=60, ncols=30, nrows=30)
r1[] <- 1:ncell(r1)
r2 <- raster(xmn=-100, xmx=-50, ymx=50, ymn=30)
res(r2) <- c(xres(r1), yres(r1))
r2[] <- 1:ncell(r2)
rm <- merge(r1, r2)

Run the code above in your browser using DataLab