I am trying to write a code in R that use gstat library in order to create an interpolation. I have already read the gstat manual and based on some examples on internet I had managed to write this code (this is only a part):
g <- gstat(id="tec", formula=TEC ~ 1, data=data) ##I create an object
v <- variogram(g) # plot the empirical variogram
plot(v)
mod<-vgm(sill=var(data$TEC),model="Sph",range=200,nugget=200) #create the variogram model
v.fit <- fit.variogram(v, model=mod,fit.method=1) #fit the empirical variogram
Theor_variogram=plot(variogram(g),v.fit,main="WLS Model") #plot the theoretical variogram
plot(Theor_variogram)
## Kriging interpolation
p <- predict.gstat(g, model=v.fit, newdata=predGrid)
My problem is that, when I run the last command (predict) instead of getting a result with ordinary kriging interpolation, I get one with inverse distance weighted (IDW). I read in the gstat manual that: "When no variograms are specified, inverse distance weighted interpolation is the default action. When variograms are specified the default prediction method is ordinary kriging."
But, as you can see in my code, I specify both the empirical and theoretical variogram. Do you know why I keep getting IDW instead of ordinary kriging? Can it be related with the type of coordinates that I have? If for example I have coordinates close to each other, or if the region of interest is too big? Any help would be really useful.
Thanks in advance Dimitris