[R-sig-Geo] krige.bayes and data export

Tomislav Hengl hengl at spatial-analyst.net
Fri Jul 24 12:01:13 CEST 2009


Hi Laura,

Sorry for a bit delay in reply. I hope you did not give up on geoR. The truth is: transforming
result of prediction using geoR to e.g. sp classes is not trivial (it looks like as creators of geoR
did not really consider this option). Once you get it into sp class, then it is easy to export it
using rgdal or to a "database format" (?). I had difficulties myself to get it running - but it is
doable. There are certainly many benefits of using geoR (actually, I am starting to like it more and
more).

> data(meuse)
> coordinates(meuse) <- ~x+y
> zinc.geo <- as.geodata(meuse.ov["zinc"])
> zinc.svar2 <- variog(zinc.geo, lambda=0, max.dist=1500, messages=FALSE)
> zinc.vgm2 <- likfit(zinc.geo, lambda=0, messages=FALSE, ini=c(var(log1p(zinc.geo$data)),500),
cov.model="exponential")
# prepare prediction locations:
> locs <- pred_grid(c(pc.comps at bbox[1,1]+gridcell/2, pc.comps at bbox[1,2]-gridcell/2),
c(pc.comps at bbox[2,1]+gridcell/2, pc.comps at bbox[2,2]-gridcell/2), by=gridcell)
...
> mask.bor <- mask at polygons[[1]]@Polygons[[1]]@coords
...
> zinc.ok2 <- krige.conv(zinc.geo, locations=locs, krige=krige.control(obj.m=zinc.vgm2),
borders=mask.bor)
...
> mask.ov <- overlay(mask, locs.sp)
> mask.sel <- !is.na(mask.ov$MASK.SGRD)
> locs.geo <- data.frame(X=locs.sp at coords[mask.sel,1], Y=locs.sp at coords[mask.sel,2],
zinc.ok2=zinc.ok2[[1]], zinc.rkvar2=zinc.ok2[[2]])
> coordinates(locs.geo) <-~X+Y
> gridded(locs.geo) <- TRUE
> write.asciigrid(locs.geo[1], "zinc_ok2.asc", na.value=-1)


Here are more examples (see section "Geostatistics in geoR"):
http://spatial-analyst.net/scripts/meuse.R 


T. Hengl


> -----Original Message-----
> From: r-sig-geo-bounces at stat.math.ethz.ch [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf
> Of Laura Poggio
> Sent: Wednesday, July 22, 2009 6:11 PM
> To: r-sig-geo at stat.math.ethz.ch
> Subject: [R-sig-Geo] krige.bayes and data export
> 
> Dear list,
> I got some simulations with krige.bayes of geoR packages. I can plot them
> with the code provided in the example. However I also would like to export
> the results of the simulations as database. This in order to access them
> later for further analysis.
> 
> To plot them I access the simulations as following:
> image(awc.res.bayes, val= "simulation", number.col=1)
> image(awc.res.bayes, val= "simulation", number.col=2)
> image(awc.res.bayes, val= "simulation", number.col=3)
> image(awc.res.bayes, val= "simulation", number.col=...)
> image(awc.res.bayes, val= "simulation", number.col=30)
> 
> I did not find a way to store the simulation values in a dataframe. And I
> did not find any example around.
> I hope I manage to explain my problem.
> 
> Thank you very much in advance
> 
> Laura Poggio
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list