简体   繁体   English

如何在 R 中实现最近邻插值法?

[英]How can I implement Nearest Neighbor interpolation method in R?

I have rainfall data that I want to interpolate using different interpolation methods.我有想要使用不同插值方法插值的降雨数据。 I have used gstat package to calculate IDW and Kriging methods.我已经使用gstat包来计算 IDW 和 Kriging 方法。

But, I am wondering about any R package and related function that I can use to perform the nearest neighbor method in the R environment.但是,我想知道我可以用来在 R 环境中执行最近邻方法的任何 R 包和相关函数。

Can any one help please?有人可以帮忙吗?

You can use gstat package for this, just set nmin and nmax parameters to 1:您可以为此使用 gstat 包,只需将 nmin 和 nmax 参数设置为 1:

idw(formula = Var ~ 1, locations = spatdat, newdata = raster,
        nmax = 1, nmin = 1, force = T, debug.level = -1)

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

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