[R] help with kriging interpolation
Mohammed Ouassou
mohammed.ouassou at statkart.no
Fri Apr 5 08:49:58 CEST 2013
Hei,
Non-parametric linear spatial interpolation algorithm Ordinary Kriging
using geoR package
library(geoR)
# 1. Create a geodata object (wMatrix contains coords and data
# ? as.geodata ---> for more info
my_geoData <- as.geodata(wMatrix, coords.col=1:2, data.col=3);
# 2. Create a variogram objects .
# ? variog ---> for more info
my_variog <- variog(my_geoData , estimator.type = c("modulus"),
max.dist= 28, uvec=seq(0,60,by=3 ), messages=FALSE);
# 3. Try to delete all dupl. in you data
my_dup = dup.coords(my_geoData$coords);
# 4. Parameter Estimation: sill, range and the nugget
# Use MLE or WLS (?likfit OR ?variofit)
reml <- likfit(my_geoData, cov.model = "wave", trend =
"cte",ini=c(my_sigmaSqrt,my_phi), fix.nugget=T,
nugget=my_nygget,lik.method = "REML",messages=F);
wls <- variofit(my_variog, ini = c(0.185, 4.05), cov.model = "mat", kap
= .5, fix.nugget=T,nug = my_nygget);
# IMPORTENT : before calling variofit() OR likfit()
# eyefit() to get appropriate init. value and covariance
# function
# 5. Perform geostatistical spatial interpolation Ord. Krig (OK)
# myPredArea: can be a single point OR a matrix
ordKrig <- krige.conv(my_geoData,
locations=myPredArea,krige=krige.control(obj.m=wls, type.krige = "ok"));
# 6. Get the predicted value and corresponding variance.
ok_pred <- cbind(myPredArea,ordKrig$predict, ordKrig$krige.var);
Mohammed Ouassou
On to., 2013-04-04 at 00:37 -0700, Jeff Newmiller wrote:
> I am no expert on kriging, but I do know that your question desperately needs a reproducible example [1] that illustrates the actual problem you are encountering.
>
> [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> ---------------------------------------------------------------------------
> Jeff Newmiller The ..... ..... Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
> Live: OO#.. Dead: OO#.. Playing
> Research Engineer (Solar/Batteries O.O#. #.O#. with
> /Software/Embedded Controllers) .OO#. .OO#. rocks...1k
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
>
> Alfred Oswago <numeros2005 at gmail.com> wrote:
>
> >All,
> >I am new to using R and know some basics. I wish to use kriging in R
> >to
> >do the following:
> >
> >given data Y =f(X1,X2,X3,.....,Xn) --1000+ irregular measured data
> >set.
> >
> >I would like to be able to get a single value y given sinle input set
> >(x1,x2,x3,...xn)
> >
> >A google search on this takes me lierally to the same example on
> >involving
> >analysis with soil sampling and I cannot figure out how to extract
> >single
> >point interpolant.
> >
> >Any examples or pointers appreciated,
> >Numeris.
> >
> > [[alternative HTML version deleted]]
> >
> >______________________________________________
> >R-help at r-project.org mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list