Learn R Programming

raster (version 1.9-13)

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 mutliple layers, the subsequent Raster objects should have the same number of layers, or have a single layer only (which will be recycled).

Arguments

Value

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

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