Search code examples
rstatisticskrigingcovariogramgeostatistics

how to change the lag distance while calculating a Variogram in R


I am trying to calculate an Experimental-Variogram value at different lag distances, so I am using the variogramm command

variog1 <- variogram((Copper)~1,ds)

but I can't know how to specify the needed lag distance. For example I want to get a value at h=(15, 30, 45, 60)


Solution

  • You can fix the lag distance in the parameter "width", or you can fix exactly the distances with the parameter "boundary". See the next example:

    library(sp)
    library(gstat)
    cord <- data.frame(x=rnorm(50,-20,6),y=rnorm(50,40,10))
    predictors <- SpatialPointsDataFrame(coords = cord, data = data.frame(val=cord$x**2+cord$y+rnorm(50,sd=0.4)),
                                         proj4string = CRS("+proj=longlat +datum=WGS84"))
    vario <- variogram(object = val ~ 1,data =  predictors,width=50)
    plot(vario)
    
    vario <- variogram(object = val ~ 1,data =  predictors,width=350)
    plot(vario)
    vario <- variogram(object = val ~ 1,data =  predictors,boundaries=c(50,100,500,700,800)) 
    plot(vario)