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

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

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

                                        Local and Focal Grid Function with Multiple Grids as Inputs
                                         电网输入多个网格,功能与本地和联络

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

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

multi.focal.function cuts out square or circular moving windows from a stack of grids (matrices) and applies a  user-defined matrix function that takes multiple arguments to this data. multi.local.function is a more efficiently coded special case of moving windows of size 0, i.e. functions applied to individual grid cells of a stack of grids. This is especially useful  for applying predict methods of statistical models to a stack  of grids containing the explanatory variables (see Examples and  grid.predict). The function is suitable for large grid files as it can process them row by row; but it may be slow because one call to the focal function
multi.focal.function从堆栈中的网格(矩阵)的方形或圆形窗口裁剪,适用于用户定义的矩阵函数,它接受多个参数,这个数据。 multi.local.function是一个更有效地移动窗口的大小为0的编码的特殊情况,即施加到单个网格单元网格堆栈的功能。施加predict统计模型的方法包含的解释变量的网格到一个堆栈,这是特别有用的(见实施例和grid.predict)。该功能适用于大电网的文件,因为它可以处理他们一行一行的,但它可能是缓慢的,因为一个调用的焦点功能


用法----------Usage----------


multi.local.function(in.grids, in.grid.prefix, out.grid.prefix,
    path = NULL, in.path = path, out.path = path,
    fun, in.varnames, out.varnames, na.strings = "NA",
    valid.ranges, nodata.values = c(), out.nodata.value,
    digits = 4, dec = ".", quiet = TRUE, nlines = Inf,
    na.action = na.exclude, pass.location = FALSE,
    ... )
multi.focal.function(in.grids, in.grid.prefix, in.factor.grid,
    out.grid.prefix, path = NULL, in.path = path, out.path = path,
    fun, in.varnames, out.varnames, radius = 0, is.pixel.radius = TRUE,
    na.strings = "NA",
    valid.ranges, 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, pass.location = FALSE, ... )



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

参数:in.grids
character vector: file names of input ASCII grids, relative to in.path; in.grid.prefix will be used as a prefix to the file name if specified; default file extension: .asc
矢量字符:文件名输入的ASCII电网,相对于in.pathin.grid.prefix将被用来作为前缀的文件名,如果指定的默认文件扩展名:.asc


参数: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)
可选的文件名,网格分类变量定义区域,区域边界作为移动窗口的特征线(见详情)


参数:in.grid.prefix
character string (optional), defining a file name prefix to be used for the input file names; a dash (-) will separate the prefix and the in.varnames  
字符串(可选),定义一个用于输入文件名的文件名前缀一个破折号(-)将分离出来的前缀和in.varnames


参数: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 out.varnames  
字符串(可选),定义一个用于输出文件名的文件名前缀;一个破折号(-)将分离出来的前缀和out.varnames


参数:path
path in which to look for in.grids and write output grid files; see also in.path and out.path, which overwrite path if they are specified
在其中寻找in.grids和写输出网格文件;in.path和out.path,它覆盖path,如果他们被指定的路径


参数:in.path
path in which to look for in.grids (defaults to path)
路径来寻找in.grids(默认为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; fun is expected to accept named arguments with the names given by in.varnames; grid.predict is a wrapper function that can be used for applying a model's predict method to a stack of grids; see Details. In multi.local.function, fun must be able to process  arguments that are vectors of equal length (e.g., a vector of 50 slope angles, another vector of 50 elevation values, etc.).
一个函数,或函数的名称,被应用在移动窗口,请参阅详细资料; fun预计接受命名参数的名称in.varnames,“grid.predict是一个包装功能,可以用于施加一个模型的predict方法的网格到一个堆栈;详细。在multi.local.function,fun必须能够处理参数向量的长度相等(例如,一个50的倾斜角度,另一个矢量矢量的50高程值,等)。


参数:in.varnames
character vector: names of the variables corresponding to the in.grids; if missing, same as in.grids; if specified, must have the same length and order as in.grids
字符向量:名称对应的变量in.grids;如果缺少一样in.grids;如果指定的话,必须具有相同的长度和顺序为in.grids


参数:out.varnames
character vector specifying the name(s) of the variable(s) returned by fun; if missing, multi.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)
返回的字符向量的变量指定的名称(S)(S)fun;如果缺少,multi.focal.function会尝试确定varnames,从fun本身,或通过调用fun如果这是一个函数(见详情)


参数: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.ranges
optional list of length length(in.grids)  with numeric vector of length 2, specifying minimum and maximum valid values read from input file; all values <valid.ranges[[i]][1] or >valid.ranges[[i]][1] will be converted to NA.
可选列表的长度length(in.grids)与的数字矢量的长度为2,指定最小和最大的有效读取的值从输入文件中的所有值<valid.ranges[[i]][1]或>valid.ranges[[i]][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的,如果丢失,使用相同的无数据输入电网的头文件中指定的值


参数: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 FALSE, gives some output ("*") after every 10th line of the grid file and when the job is done.
如果FALSE,使一些输出("*")后,每十号线的网格文件和工作已经完成。


参数:nlines
Number of lines to be processed; useful for testing purposes.
被处理的行数,可用于测试目的。


参数:na.action
function: determines if/how NA values are omitted from the stack of input variables; use na.exclude (default) or na.pass if fun can handle NA values correctly  
功能:判断是否/如何NA值被省略的输入变量从堆栈中使用na.exclude(默认)或na.pass如果fun可以处理NA值正确地


参数: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。


参数:pass.location
logical: Should the x,y coordinates of grid points (center of grid cells) be passed to fun? If TRUE, two additional arguments named arguments x and y are passed to fun; NOTE: This currently only works for radius=0, otherwise a warning is produced and pass.location is reset to FALSE.
逻辑:如果x,y坐标的网格点(网格单元中心)传递给fun?如果TRUE,两个额外的参数命名的参数x和y传递给fun;注意:这目前仅适用于radius=0,否则警告是和pass.location重置到FALSE。


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


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


Details

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

multi.local.function is probably most useful for applying the predict method of a fitted model to a grids representing the  predictor variables. An example is given below and in more detail  in Brenning (2008) (who used multi.focal.function for the same purpose); see also grid.predict.
multi.local.function可能是最有用的应用predict方法的拟合模型的预测变量代表一个网格。下面给出一个例子,更详细在Brenning(2008)(使用multi.focal.function为同样的目的);又见grid.predict。

multi.local.function is essentially the same as multi.focal.function for radius=0, but coded MUCH more efficiently. (The relevant code will eventually migrate into multi.focal.function as well, but requires further testing.) Applying a GAM to the data set of Brenning (2008) takes about 1/100th the time with multi.local.function compared to multi.focal.function.
multi.local.function作为multi.focal.functionradius=0本质上是相同的,但更有效的编码MUCH。 (相关的代码最终会迁移到multi.focal.function好,但还需要进一步的测试。),应用GAM的Brenning(2008年)的数据,需要约百分之一的时间multi.local.function相比, multi.focal.function。

multi.focal.function extends focal.function by allowing multiple input grids to be passed to the focal function fun operating on moving windows. It passes square matrices 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; one such matrix or vector per input grid will be passed to fun as an argument whose name is specified by in.varnames.
multi.focal.function延伸focal.function通过允许将被传递给多个输入电网的焦点功能fun上操作移动窗口。它的功能2*radius+1如果fun(默认),或一个矢量的长度mw.to.vector=FALSE如果<=(2*radius+1)^2;这样一个矩阵或传递方阵的大小mw.to.vector=TRUE矢量将被传递给每输入电网fun作为参数的名称是指定的in.varnames。

These matrices or vectors 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.
将包含这些矩阵或向量的移动窗口的内容,这可能会包含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, such as a regression result or a vector of class probabilities returned by a soft classifier. In addition to the named arguments receiving the moving window data, fun may have additional arguments; the ... argument of focal.function is passed on to fun. grid.predict uses this feature.
函数fun应该返回一个单一的数值或数值向量,如回归的结果或返回软分类的向量类的概率。除了命名参数移动窗口的数据,fun可能有额外的参数; ...参数focal.function被传递到fun的。 grid.predict使用此功能。

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.
或者,fun应该支持以下功能:如果没有参数传递给它,然后它应该返回给变量的名字被用于命名输出电网的字符向量。

For the input files, .asc is used as the default file extension, if it is not specified by the user.
对于输入文件,.asc被用作默认文件扩展名,如果它没有由用户指定的,。

See focal.function for details.
见focal.function的详细信息。


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

multi.focal.function returns the
multi.focal.function返回


注意----------Note----------

multi.focal.function can do all the things focal.function
multi.focal.function可以做所有的事情focal.function


(作者)----------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----------

focal.function, grid.predict
focal.function,grid.predict


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


## Not run: [#不运行:]
# Assume that d is a data.frame with point observations[假设d是点观测数据框]
# of a numerical response variable y and predictor variables[响应变量y的数值和预测变量]
# a, b, and c.[,b,和c。]
# Fit a generalized additive model to y,a,b,c.[一个广义相加模型拟合Y,A,B,C。]
# We want to model b and c as nonlinear terms:[我们要的非线性模型B和C:]
require(gam)
fit <- gam(y ~ a + s(b) + s(c), data = d)
multi.local.function(in.grids = c("a", "b", "c"),
    out.varnames = "pred",
    fun = grid.predict, fit = fit )
    # Note that the 'grid.predict' uses by default the[需要注意的是默认情况下,使用“grid.predict”]
    # predict method of 'fit'.[适合的预测方法。]
# Model predictions are written to a file named pred.asc[模型的预测被写入到一个文件名为pred.asc]

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

## Not run: [#不运行:]
# A fake example of a logistic additive model:[一个假的MF添加剂模型的例子:]
require(gam)
fit <- gam(cl ~ a + s(b) + s(c), data = d, family = binomial)
multi.local.function(in.grids = c("a", "b", "c"),
    out.varnames = "pred",
    fun = grid.predict, fit = fit,
    control.predict = list(type = "response") )
    # 'control.predict' is passed on to 'grid.predict', which[control.predict被传递到grid.predict,其中]
    # dumps its contents into the arguments for 'fit''s[其内容转储到适合的论点,]
    # 'predict' method.[“预测”的方法。]
# Model predictions are written to a file named pred.asc[模型的预测被写入到一个文件名为pred.asc]

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

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-27 04:02 , Processed in 0.025705 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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