NA
.
New values are computed with function fun
, using the values of the cells in the neigborhood of a focal cell (including the focal cell).focal(x, ngb=3, fun=mean, na.rm=TRUE, filename="", ...)
focalNA(x, ngb=3, fun=mean, recursive=FALSE, maxrec=0, filename="", ...)
ngb=3
refers to 2 cells at each side of the focal cell, qeen's case, 9 cells in total. This is equivalent tlengt
TRUE
, NA
will be removed from focal computations. The result will only be NA
if all focal cells are NA
TRUE
, the function will continue recursively untill there are no more cells with NA
recursive=TRUE
)overwrite
Logical. If TRUE
, "filename" will be overwritten if it exists
format
Character. Output file type. See writeRaster
datatype
Character. Output data type. See dataType
progress
Character. "text", "window", or "" (the default, no progress bar)
}focalFilter
, focalValues
r <- raster(ncols=36, nrows=18)
r[] <- runif(ncell(r))
rf <- focal(r, fun=mean, ngb=3)
Run the code above in your browser using DataLab