raster (version 2.1-41)

cover: Replace NA values with values of other layers

Description

Replace NA values in the first Raster object (x) with the values of the second (y), and so forth for additional Rasters. If x has multiple layers, the subsequent Raster objects should have the same number of layers, or have a single layer only (which will be recycled).

Usage

cover(x, y, ...)

Arguments

x
Raster* object
y
Raster* object
...
Additional Raster objects, and additional arguments as for writeRaster

Value

  • RasterLayer or RasterBrick object

Examples

Run this code
r1 <- raster(ncols=36, nrows=18)
r1[] <- 1:ncell(r1)
r2 <- setValues(r1, runif(ncell(r1)))
r2[r2<0.5] <- NA
r3 <- cover(r2, r1)

Run the code above in your browser using DataLab