[英]R angular distance weighting interpolation function
I would like use R for doing an Angular-Distance-Weighting Interpolation as described eg here (p. 3).我想使用的R用做一个角度一距离加权插值如例如在这里(第3页)。
It is an interpolation which (1) weights the data points by distance relative to a correlation decay distance and (2) gives more weight to isolated data points.它是一种插值,它 (1) 通过相对于相关衰减距离的距离对数据点进行加权,并且 (2) 为孤立的数据点赋予更多权重。
My question is whether there is some package implementation of this in R or whether one would need to do it from scratch.我的问题是在 R 中是否有一些包实现,或者是否需要从头开始。 My Google search did not get me anything obvious on this but I do not know R's interpolation packages so well.
我的谷歌搜索没有给我任何明显的信息,但我不太了解 R 的插值包。 So if anybody has ever done this, please let me know.
所以如果有人做过这件事,请告诉我。
There is no R package available..I wrote a simple function for Angular distance weighting (ADW) as implemented in Shepard 1968没有可用的 R 包。我为 Angular 距离加权 (ADW) 编写了一个简单的函数,如 Shepard 1968 中实现的
[X,Y] are coordinates where you wish to estimate. [X,Y] 是您希望估计的坐标。 [Xtrain,Ytrain] are the coordinates of data points.
[Xtrain,Ytrain] 是数据点的坐标。 weights radial are the weights by distance.
径向权重是按距离计算的权重。
compute_weight_by_theta = function(X,Y,xtrain,ytrain,weights.radial){
N = length(xtrain)
weight.directional = integer(N)
for (i in 1:N){
numerator = 0;
denominator = 0;
for (j in 1:N){
xi = xtrain[i]; yi = ytrain[i]
xj = xtrain[j]; yj = ytrain[j]
if ((xi != xj) | (yi != yj)){
Sj = weights.radial[j]
Di = sqrt((X - xi)**2 + (Y - yi)**2)
Dj = sqrt((X - xj)**2 + (Y - yj)**2)
cos_theta = ((X-xi)*(X-xj) + (Y-yi)*(Y-yj)) / (Di*Dj)
numerator = numerator + (1-cos_theta)*Sj
denominator = denominator + Sj
}
}
weight.directional[i] = numerator/denominator
}
return(weight.directional)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.