0

クリギング補間の出力であるグリッドと、補間が必要ないくつかのポイントとの間の距離を計算する必要があります。

問題は、グリッドが非常に大きく、グリッドのポイントとパッケージgeodDistからの関心のあるポイントとの間の距離を計算するサイクルの平凡な2倍にするのに永遠にかかることです。oce

グリッド内のどの点が関心のある点に近いかを計算するより良い方法はありますか??

これが私の平凡なサイクルです

#find the closest points from the grid to the old samples
#kriging model and so on y_ok now contains the grid

y_ok <- krige(rssi~1, samples, predgrid, model = vfit_ok, nmax=5)

yok.fr<-as.data.frame(y_ok)
#samples_all.fr contains the points where I want to interpolate
require(oce)
dist.mtx<-matrix(data=NA,nrow=dim(samples_all.fr)[1],ncol=2)

for (i in 1:2){#dim(samples_all.fr[1])){
  for(j in 1:dim(yok.fr)[1]){
    a=geodDist(samples_all.fr[i,2], samples_all.fr[i,1], yok.fr[j,2], yok.fr[j,1])
    if(!(is.finite(dist.mtx[i,1]))|(a<dist.mtx[i,1])){
      dist.mtx[i,1]=a
      dist.mtx[i,2]=j
    } 
  }
}

これは単なるベスト プラクティスの質問なので、データは含めません。問題ないことを願っています。

4

1 に答える 1

0

カールが示唆するように、関数の適用ファミリを使用すると計算が高速化される場合があります

 ??apply

並列処理も検討したい場合があります

于 2014-04-19T13:16:21.747 に答える