Learn R Programming

raster (version 1.0.0-1)

merge: Merge RasterLayers

Description

Merge RasterLayers to form a new RasterLayer with a larger spatial extent

Usage

merge(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. In areas where the RasterLayers overlap, the values of the RasterLayer that is first in the sequence of arguments will be retained.

See Also

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