找回密码
 注册
查看: 422|回复: 0

R语言 RSAGA包 focal.function()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-28 21:16:24 | 显示全部楼层 |阅读模式
focal.function(RSAGA)
focal.function()所属R语言包:RSAGA

                                        Local and Focal Grid Functions
                                         本地和震源网格功能

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

focal.function cuts out square or circular moving windows from a grid (matrix) and applies a user-defined matrix function to calculate e.g. a terrain attribute or filter the grid. The function is suitable for large grid files as it can process them row by row. local.function represents the special case of a moving window of radius 1. Users can define their own functions operating on moving windows, or use simple functions such as median to
focal.function切出方形或圆形的移动窗口从一个网格(矩阵),并适用于例如一个用户定义的矩阵函数来计算一个的地形属性或过滤电网。的功能是合适的,大格档,因为它可以处理他们一行一行地。 local.function代表的移动窗口的半径为1的特殊情况。用户可以定义自己的函数运行在移动窗口,或使用简单的功能,如median


用法----------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, dec = ".", quiet = TRUE, nlines = Inf,
    mw.to.vector = FALSE, mw.na.rm = FALSE, ...)
local.function(...)
gapply(in.grid, fun, varnames, mw.to.vector=TRUE, mw.na.rm=TRUE, ...)



参数----------Arguments----------

参数:in.grid
file name of input ASCII grid, relative to in.path
文件名称输入ASCII格,相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  
字符串(可选),定义一个用于输出文件名的文件名前缀;一个破折号(-)将分离出来的前缀和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.grid和写输出网格文件;in.path和out.path,它覆盖path,如果他们被指定的路径


参数:in.path
path in which to look for in.grid (defaults to path)
路径来寻找in.grid(默认为path)


参数:out.path
path in which to write output grid files; defaults to path
在其中写入输出网格文件的路径,默认为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 or from a call to fun if this is a function (see Details)
返回fun;如果缺少,focal.function会尝试确定varnames,从fun本身,或通过调用<X字符向量确定的变量的名称(S) >如果这是一个函数(见详情)


参数: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 will be included in the moving window, not <radius.
指定移动窗口半径(圆形或方形)的数值,请参阅is.pixel.radius和search.mode;注意,距离<=radius将包括在移动窗口内的所有数据,不<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.
逻辑:TRUE如果(默认),radius将被解释为一个(可能非整数)的像素数;如果FALSE,它被解释为半径测量电网(图)为单位。


参数:valid.range
numeric vector of length 2, specifying minimum and maximum valid values read from input file; all values <valid.range[1] or >valid.range[1] will be converted to NA.
数字矢量的长度为2,指定最小和最大的有效读取的值从输入文件中的所有值<valid.range[1]或>valid.range[1]将被转换到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
数字矢量输入网格文件,该文件应该被转换为NA的任何值,除了无数据网格标头中指定的值


参数:out.nodata.value
numeric: value used for storing NAs in the output file(s); if missing, use the same nodata value as specified in the header of the input grid file
数字值,用于存储在输出文件中(S)NA的,如果丢失,使用相同的无数据输入电网的头文件中指定的值


参数:na.strings
passed on to scan
通过scan


参数:search.mode
character, either "circle" (default) for a circular search window, or "square" for a squared one.
字符,无论是"circle"(默认)一个圆形的搜索窗口,或"square"的平方。


参数:digits
numeric, specifying the number of digits to be used for output grid file.
数值,指定要用于输出网格文件的数字的数量。


参数: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.
如果TRUE,使一些输出("*")后,每十号线的网格文件和工作已经完成。


参数: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 NAs be removed from moving window prior to passing the data to fun? Only applicable when mw.to.vector=TRUE.
逻辑:如果从NA的移动窗口之前,将数据传递到fun?只适用于mw.to.vector=TRUE。


参数:...
Arguments to be passed to fun; local.function: arguments to be passed to  focal.function.
参数被传递给fun,“local.function:参数被传递到focal.function。


Details

详细信息----------Details----------

focal.function passes a square matrix of size 2*radius+1 to the function fun if mw.to.vector=FALSE (default), or a vector of length <=(2*radius+1)^2 if mw.to.vector=TRUE. This matrix or vector will contain the content of the moving window, which may possibly contain NAs even if the in.grid has no nodata values, e.g. due to edge effects. If search.mode="circle", values more than radius units (pixels or grid units, depending on is.pixel.radius) away from the center pixel / matrix entry will be set to NA. In addition, valid.range, nodata.values, and the nodata values specified in the in.grid are checked to assign further NAs to pixels in the moving window. Finally, if 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.
focal.function通过一个方阵的大小2*radius+1的功能fun如果mw.to.vector=FALSE(默认),或一个向量的长度<=(2*radius+1)^2如果mw.to.vector=TRUE 。将包含此矩阵或矢量的移动窗口的内容,这可能会包含NA的,即使in.grid没有无数据值,例如由于边缘效应。如果以上search.mode="circle"单位(像素或网格单元,根据radius)远离中心像素/矩阵输入的is.pixel.radius,值将被设置为NA。此外,valid.range,nodata.values,和无数据中指定的值的in.grid进行检查,以进一步分配NA的移动窗口的像素。最后,如果in.factor.grid指定区域,属于不同的区域比中心像素的移动窗口中的所有像素被设置为NA,或者,换句话说,区域的边界作为断线。

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.
的功能fun应该返回一个单一的数值或数值向量。作为一个例子,该函数resid.minmedmax返回最小值,中值和最大的移动窗口中的值之间的差和中心网格单元中的值。除了移动窗口的数据(第一个)参数,fun可能有额外的参数; ...的focal.function参数被传递到fun。 resid.quantile是一个功能,使用此功能。

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.
或者,fun应该支持以下功能:如果没有参数传递给它,然后它应该返回给变量的名字被用于命名输出电网的字符向量。呼叫resid.minmedmax(),例如,退货c("rmin","rmed","rmax");作为移动窗口的数据时,传递给函数的返回的数字矢量,这个向量必须具有相同的长度。此功能仅用于如果没有varnames参数。请注意的结果是目前正在abbreviateD 6个字符的长度。

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
输入:[<in.path>/]<in.grid>区:[<in.path>/]<in.factor.grid>(如果指定的话)输出:[<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.
对于输入文件,.asc被用作默认文件扩展名,如果它没有由用户指定的,。


值----------Value----------

focal.function and local.function return the
focal.function和local.function返回


注意----------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
这些功能是不是很有效的方式计算,如(焦点)地形属性,例如SAGA模块相比,但这个想法是,你可以很容易地指定自己的功能,而开始向周围的混乱的C代码。例如,尝试实施中位数过滤器


(作者)----------Author(s)----------


Alexander Brenning



参考文献----------References----------

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),

参见----------See Also----------

multi.focal.function, multi.local.function, resid.median, resid.minmedmax, relative.position, resid.quantile, resid.quartiles, relative.rank,
multi.focal.function,multi.local.function,resid.median,resid.minmedmax,relative.position,resid.quantile,resid.quartiles,relative.rank,


实例----------Examples----------


## Not run: [#不运行:]
# A simple median filter applied to dem.asc:[一个简单的中值滤波适用于dem.asc:]
gapply("dem","median",radius=3)
# Same:[相同的:]
#focal.function("dem",fun="median",radius=3,mw.to.vector=TRUE,mw.na.rm=TRUE)[focal.function(“DEM”,有趣的“中位数”,半径= 3,mw.to.vector = TRUE,mw.na.rm = TRUE)]
# See how the filter has changed the elevation data:[过滤器已经改变了高程数据:]
d1 = as.vector(read.ascii.grid("dem")$data)
d2 = as.vector(read.ascii.grid("median")$data)
hist(d1-d2,br=50)

## End(Not run)[#(不执行)]
# Wind shelter index used by Plattner et al. (2004):[的避风指数使用由普拉特纳等人。 (2004):]
## Not run: [#不运行:]
ctrl = wind.shelter.prep(6,-pi/4,pi/12,10)
focal.function("dem",fun=wind.shelter,control=ctrl,
    radius=6,search.mode="circle")

## End(Not run)[#(不执行)]
# Or how about this, if "aspect" is local terrain exposure:[这个怎么样,如果“纵横”是当地的地形曝光:]
## Not run: [#不运行:]
gapply("aspect","cos") # how "northerly-exposed" is a pixel?[“北风暴露”是像素?]
gapply("aspect","sin") # how "easterly-exposed" is a pixel?[如何的“东风暴露”是像素?]
# Same result, but faster:[同样的结果,但速度更快:]
focal.function("aspect",fun=function(x) c(cos(x),sin(x)), varnames=c("cos","sin"))

## End(Not run)[#(不执行)]

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-27 03:55 , Processed in 0.027235 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表