[R-sig-Geo] Help for cokriging

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed Jun 20 21:58:34 CEST 2012


in fit.lmc(), use fit.lmc = TRUE.

otherwise, in spsample, I'd use type = "regular".

On 06/20/2012 08:36 PM, Sasan Sasani wrote:
> 
> 
> Dear All.
> I am very new in programing. I try to perform a cokriging in gstat.
> I have four variable and coordinates of each variables are differ(non-Collocated model).
> Each variable and its coordinates are saved in d1-d4 text file.
> My program for fitting cross-variogram is:
> 
> m<-vgm(1954,"Gau",80017,225)
> g <- gstat(NULL, id = "k", form =k ~ 1,data=d1)
> g <- gstat(g, id = "hgrad", form =hgrad~ 1,data=d2)
> g <- gstat(g, id = "res", form =res~ 1,data=d3)
> g <- gstat(g, id = "wtab", form =wtab~ 1,data=d4)
> vm <- variogram(g)
> vm.fit <- fit.lmc(vm, g, model=m,fit.ranges =F, fit.lmc =F)
> plot(vm, vm.fit,main="Empirical and Fitted Cross-Variogram ",col="black",pch=20)
> 
> I have two problem:
> 
> 1- How can I make a grid with shapefile(like meuse.grid). I want my results plot in my map.
> My program for create a grid is:
> gg<-spsample(shapefile,n=1000,type="nonaligned",cellsize=200)
> plot(gg)
> coordinates(gg)<-~x+y
> gridded(gg) <- TRUE 
> grd = as(gg, "SpatialPixels") 
> image(grd) 
> 
> 2-How can I perform cokriging
> When I crate a grid with below program:
> x.range <- as.integer(range(d1 at coords[,1]))
> y.range <- as.integer(range(d1 at coords[,2]))
> plot(x.range,y.range)
> grd <- expand.grid(x=seq(from=x.range[1], to=x.range[2], 
> by=500), y=seq(from=y.range[1], to=y.range[2], by=500) )
> coordinates(grd) <- ~ x+y
> gridded(grd) <- TRUE
> The cokriging run by Inverse distance but I try to perform ordinary cokriging.
> 
> 
> 3-When I use below program for ceate grid and perform predict
>  
> gg<-spsample(shapefile,n=1000,type="nonaligned",cellsize=200)
> plot(gg)
> coordinates(gg)<-~x+y
> gridded(gg) <- TRUE 
> grd = as(gg, "SpatialPixels") 
> image(grd) 
> cok.maps <- predict(vm.fit, meuse.grid)
> The Erorr is:
> Error in predict.gstat(vm.fit, grd) : 
>   gstat: value not allowed for: variograms do not satisfy a legal model
> 
> What do I do?
> 
> 	[[alternative HTML version deleted]]
> 
> 
> 
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list