简体   繁体   English

R gstat中的空间插值,不显示消息

[英]Spatial interpolation in R gstat without the message

When I'm doing interpolation in R using gstat package, the message like this '[inverse distance weighted interpolation]' or this '[ordinary or weighted least squares prediction] ' occurs. 当我使用gstat软件包在R中进行插值时,会出现类似“ [[距离反距离加权插值]”或“ [普通或加权最小二乘预测]”的消息。 Eg: 例如:

library('sp')
library('gstat')
data(meuse)
coordinates(meuse) = ~x + y 
data(meuse.grid)
coordinates(meuse.grid) = ~x + y 
gridded(meuse.grid) <- TRUE
zn.tr1 <- krige(log(zinc) ~  x + y , meuse, meuse.grid)

[ordinary or weighted least squares prediction] [普通或加权最小二乘预测]

How to disable that message? 如何禁用该消息?

或将调试级别设置为默认值以下的一种:

zn.tr1 <- krige(log(zinc) ~  x + y , meuse, meuse.grid, debug.level = 0)

Various ways exist of stopping output - the nicest being if the function has an option to suppress it. 存在多种停止输出的方法-最好的方法是该函数具有禁止输出的选项。 But krige doesn't seem to have that. 但是krige似乎没有。

capture.output works here: capture.output在这里工作:

> rm(zn.tr1)
> zn.tr1 # there is no zn.tr1
Error: object 'zn.tr1' not found
> z = capture.output(zn.tr1 <- krige(log(zinc) ~  x + y , meuse, meuse.grid))
> str(zn.tr1) # there is now
Formal class 'SpatialPixelsDataFrame' [package "sp"] with 7 slots
  ..@ data       :'data.frame': 3103 obs. of  2 variables:
  .. ..$ var1.pred: num [1:3103] 6.16 6.18 6.14 6.1 6.19 ...

The output message itself is returned and stored in z 输出消息本身返回并存储在z

> z
[1] "[ordinary or weighted least squares prediction]"

But if you don't print it you won't see it. 但是,如果您不打印它,您将看不到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM