Download Package `RSAGA`
Transcript
focal.function
7
in.factor.grid specifies zones, all pixels in the moving window that belong to a different zone
than the center pixel are set to NA, or, in other words, zone boundaries are used as breaklines.
The function fun should return a single numeric value or a numeric vector. As an example, the
function resid.minmedmax returns the minimum, median and maximum of the difference between
the values in the moving window and the value in the center grid cell. In addition to the (first)
argument receiving the moving window data, fun may have additional arguments; the ... argument
of focal.function is passed on to fun. resid.quantile is a function that uses this feature.
Optionally, fun should support the following feature: If no argument is passed to it, then it should
return a character vector giving variable names to be used for naming the output grids. The call
resid.minmedmax(), for example, returns c("rmin","rmed","rmax"); this vector must have the
same length as the numeric vector returned when moving window data is passed to the function.
This feature is only used if no varnames argument is provided. Note that the result is currently
being abbreviated to a length of 6 characters.
Input and output file names are built according to the following schemes:
Input: [<in.path>/]<in.grid>
Zones: [<in.path>/]<in.factor.grid> (if specified)
Output: [<out.path>/][<out.grid.prefix>-]<varnames>.asc
For the input files, .asc is used as the default file extension, if it is not specified by the user.
Value
focal.function and local.function return the character vector of output file names.
Note
These functions are not very efficient ways of calculating e.g. (focal) terrain attributes compared
to for example the SAGA modules, but the idea is that you can easily specify your own functions
without starting to mess around with C code. For example try implementing a median filter as a
SAGA module... or just use the code shown in the example!
Author(s)
Alexander Brenning
References
Brenning, A. (2008): Statistical geocomputing combining R and SAGA: The example of landslide
susceptibility analysis with generalized additive models. In: J. Boehner, T. Blaschke, L. Montanarella (eds.), SAGA - Seconds Out (= Hamburger Beitraege zur Physischen Geographie und
Landschaftsoekologie, 19), 23-32.
See Also
multi.focal.function, multi.local.function, resid.median, resid.minmedmax, relative.position,
resid.quantile, resid.quartiles, relative.rank, wind.shelter, create.variable.name