[R-sig-Geo] Fw: Help for cokriging

Tom Gottfried tom.gottfried at o2mail.de
Sat Jun 23 14:31:44 CEST 2012


Sasan,

Am 23.06.2012 13:34, schrieb Sasan Sasani:
>
>
>
> 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)

setting fit.lmc=TRUE should avoid the below error message telling you 
that you don't have a legal model (see ?fit.lmc).

> plot(vm, vm.fit,main="Empirical and Fitted Cross-Variogram ",col="black",pch=20)
>
> I have three 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)

To me it seems too hard to guess what the object shapefile is. You 
should provide a reproducible example.

> 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.

You do not show how you tried cokriging here. But most probably you did 
not provide a variogram model.

> 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

See above.

> What do I do?

Trying to construct reproducible examples, e.g. with meuse data, often 
helps in spotting the errors oneself.

HTH,
Tom

> 	[[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



More information about the R-sig-Geo mailing list