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 tTRUE, NA will be removed from focal computations. The result will only be NA if all focal cells are NATRUE, the function will continue recursively untill there are no more cells with NArecursive=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. Valid values are "text", "tcltk", "windows" (on that platform only) and ""
}focalFilter, focalValuesr <- 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