Learn R Programming

raster (version 1.9-44)

approxNA: Estimate values for cells that are NA

Description

approxNA uses the stats function approx to estimate values for cells that are NA by interpolation across layers. For estimation based on neighboring cells see focal

Usage

approxNA(x, ...)

Arguments

x
RasterStack or RasterBrick object
...
additional arguments as in approxfun (except for x, y, which cannot be used)

Value

  • RasterBrick

See Also

focal

Examples

Run this code
r <- raster(ncols=5, nrows=5)
r1 <- setValues(r, runif(ncell(r)))
r2 <- setValues(r, runif(ncell(r)))
r3 <- setValues(r, runif(ncell(r)))
r4 <- setValues(r, runif(ncell(r)))
r5 <- setValues(r, NA)
r6 <- setValues(r, runif(ncell(r)))
r1[1:10] <- NA
r2[5:15] <- NA
r3[8:25] <- NA
s <- stack(r1,r2,r3,r4,r5,r6)
x1 <- approxNA(s)
x2 <- approxNA(s, rule=2)

Run the code above in your browser using DataLab