Usage
focal.function(in.grid, in.factor.grid, out.grid.prefix, path = NULL, in.path = path, out.path = path, fun, varnames, radius = 0, is.pixel.radius = TRUE, na.strings = "NA", valid.range = c(-Inf, Inf), nodata.values = c(), out.nodata.value, search.mode = c("circle", "square"), digits = 4, hdr.digits = 10, dec = ".", quiet = TRUE, nlines = Inf, mw.to.vector = FALSE, mw.na.rm = FALSE, ...)
gapply(in.grid, fun, varnames, mw.to.vector = TRUE, mw.na.rm = TRUE, ...)
local.function(...)
Arguments
in.grid
file name of input ASCII grid, relative to in.path
in.factor.grid
optional file name giving a gridded categorical variables defining zones; zone boundaries are used as breaklines for the moving window (see Details)
out.grid.prefix
character string (optional), defining a file name prefix to be used for the output file names; a dash (-
) will separate the prefix and the varnames
path
path in which to look for in.grid
and write output grid files; see also in.path
and out.path
, which overwrite path
if they are specified
in.path
path in which to look for in.grid
(defaults to path
)
out.path
path in which to write output grid files; defaults to path
fun
a function, or name of a function, to be applied on the moving window; see Details
varnames
character vector specifying the names of the variable(s) returned by fun
; if missing, focal.function
will try to determine the varnames from fun
itself, or from a call to fun
if this is a function (see Details)
radius
numeric value specifying the (circular or square) radius of the moving window; see is.pixel.radius
and search.mode
; note that all data within distance <=radius< code=""> will be included in the moving window, not .
=radius<>
is.pixel.radius
logical: if TRUE
(default), the radius
will be interpreted as a (possibly non-integer) number of pixels; if FALSE
, it is interpreted as a radius measured in the grid (map) units.
valid.range
numeric vector of length 2, specifying minimum and maximum valid values read from input file; all values or >valid.range[1]
will be converted to NA
.
nodata.values
numeric vector: any values from the input grid file that should be converted to NA
, in addition to the nodata value specified in the grid header
out.nodata.value
numeric: value used for storing NA
s in the output file(s); if missing, use the same nodata value as specified in the header of the input grid file
search.mode
character, either "circle"
(default) for a circular search window, or "square"
for a squared one.
digits
numeric, specifying the number of digits to be used for output grid file.
hdr.digits
numeric, specifying the number of digits to be used for the header of the output grid file (default: 10; see write.ascii.grid.header
). dec
character, specifying the decimal mark to be used for input and output.
quiet
If TRUE
, gives some output ("*"
) after every 10th line of the grid file and when the job is done.
nlines
Number of lines to be processed; useful for testing purposes.
mw.to.vector
logical: Should the content of the moving window be coerced (from a matrix) to a vector?
mw.na.rm
logical: Should NA
s be removed from moving window prior to passing the data to fun
? Only applicable when mw.to.vector=TRUE
.
...
Arguments to be passed to fun
; local.function
: arguments to be passed to focal.function
.