Learn R Programming

raster (version 2.0-41)

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. Layers are considered equidistant, unless an argument 'z' is used, or getZ returns values, in which case these values are used to determine distance between 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) and an additional argument 'z' to indicate the distance between layers (e.g., time, depth)

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)

x3 <- approxNA(s, rule=2, z=c(1,2,3,5,14,15))

Run the code above in your browser using DataLab