[R-sig-Geo] problem in cokriging plot

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed Jan 11 12:02:39 CET 2012


Saman, in communicating these things it would be helpful if you provided
examples that we can reproduce, with data that are available in the
packages.

For instance, I'm sure your command

grided(grd)~c("x","y")

will have caused an error message, because it is plain wrong. Whether
this is a mistake in your email, or whether you simply ignored the error
message (never a good idea) is now unclear.

On 01/11/2012 11:30 AM, Saman Monfared wrote:
> Hi.
> I have some problems in prediction of cokriging
> 
> 1)- I don't know how make a grid for prediction, I have a polygone and I select
> 3000 points into this polygone. I want make grid like "meuse.grid"
> 
> nc.sids <- readShapePoly("City Boundary.shp")
> pts <- spsample(nc.sids, n=3000, type="regular")
> grd<-data.frame(pts)
> grided(grd)~c("x","y")
> 
> 
> 2)- I have problem for predict and plot results of cokriging:
> 
> coordinates(dd) = ~x+y
> m<-vgm( 0.22493303,"Gau",78006.24,0,cutoff=100607.2, width = 100607.2/12)
> g <- gstat(NULL, id = " B", form =  B ~1,data=dd,fill.cross = F)
> g <- gstat(g, id = "A", form = A~1,data=dd,fill.cross = F)
> g <- gstat(g, id = "T", form =  T~ 1,data=dd,fill.cross = F)
> vm <- variogram(g,covariance=F)
> plot(vm)
> vm.fit <- fit.lmc(vm, g, model=m,fit.ranges =F)
> plot(vm, vm.fit)
> 
> z<-predict(vm.fit,grd)
> 
> R output:
> 
> Error in function (classes, fdef, mtable)  :
>   unable to find an inherited method for function "proj4string", for
> signature "data.frame"
> 
> 
> when I use
> 
> pts <- spsample(nc.sids, n=3000, type="regular")
> grd <- as(pts, "SpatialPixels")
> grided(grd)~c("x1","x2")
> .
> .
> .
> z<-predict(vm.fit,grd)
> and when I use
>  spplot(z,contour=T)
> 
> it is plot not all of predictions and thier variances only plot some of them.
> 
> when I want plot predictions or covariances
> 
> image(z["B.var"],col = "beige")
> 
> R output is:
> 
> Error in `[.data.frame`(x at data, i, j, ..., drop = FALSE) :
>   undefined columns selected
> 
> how can I plot all three prediction variables and thier variances????
> 
> _______________________________________________
> 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