[R-sig-Geo] kriging: export to grid

Paulo Justiniano Ribeiro Jr paulojus at c3sl.ufpr.br
Tue Dec 16 23:17:55 CET 2008


Hi Edzer

Thanks for the feed back.

And yes I agree this is a nice design - the type of input define the type
of output, and, besides that, output.control() can have an
option do explicitly specify the required output format.
If we have the converters, is just a matter of call it internally.

class "geodata" already converts from and to SpatialPointsDataFrame
by this should be extended to (bayesian)kriging outputs

More generally geoR should accept sp object as inputs not only in the
locations arguments but also as data

... and more generally geoR2 should have a completely new design fully
compatible with sp --- I need a sabatical!!!!!

thanks and best regards!


Paulo Justiniano Ribeiro Jr
LEG (Laboratorio de Estatistica e Geoinformacao)
Universidade Federal do Parana
Caixa Postal 19.081
CEP 81.531-990
Curitiba, PR  -  Brasil
Tel: (+55) 41 3361 3573
Fax: (+55) 41 3361 3141
e-mail: paulojus AT  ufpr  br
http://www.leg.ufpr.br/~paulojus



On Tue, 16 Dec 2008, Edzer Pebesma wrote:

> Hi Paulo,
>
> you suggest to add conversion functions to geoR later on, but I (as the
> average lazy user) would ask the following: if in the following geoR call
>
> kc.s <- krige.conv(s100, loc=gr.s, krige=krige.control(obj=ml.s))
>
>
> gr.s is of class SpatialPixels[DataFrame] or SpatialGrid[DataFrame],
> could, as output, the object kc.s be of that same class? You could argue
> this is incompatible, but a call like that was never supposed to work so
> you could call it progress as well. And it saves me the conversion. Of
> course, gr.s and kc.s could be of class SpatialPoints[DataFrame] as well.
>
> Bests regards,
> --
> Edzer
>
> Paulo Justiniano Ribeiro Jr wrote:
> > I've just added to the geoR tutorial page an script with examples
> > on converting geoR's krige.conv() outputs to
> > SpatialGridDataFrame and SpatialPixelDataFrame formats defined by the sp
> > package
> >
> > The relevant link is:
> > http://leg.ufpr.br/geoR/tutorials/kc2sp.R
> >
> > These should be encapsulated on function in a (hopefully) near future
> > to facilitate conversion of outputs from both, krige.conv() and
> > krige.bayes()
> >
> >
> > As usual, comments/suggestions/improvements etc are very welcome!
> >
> > Best
> > P.J.
> >
> >
> > Paulo Justiniano Ribeiro Jr
> > LEG (Laboratorio de Estatistica e Geoinformacao)
> > Universidade Federal do Parana
> > Caixa Postal 19.081
> > CEP 81.531-990
> > Curitiba, PR  -  Brasil
> > Tel: (+55) 41 3361 3573
> > Fax: (+55) 41 3361 3141
> > e-mail: paulojus AT  ufpr  br
> > http://www.leg.ufpr.br/~paulojus
> >
> >
> >
> > On Sun, 14 Dec 2008, Roger Bivand wrote:
> >
> >
> >> On Sun, 14 Dec 2008, Nicolas Meurisse wrote:
> >>
> >>
> >>> Hello,
> >>>
> >>> After kriging with the use of the  krige.conv function, I would like to
> >>> export my result under the grid format. In order to view it into a GIS.
> >>>
> >>> It was suggested to me to use the writeGDAL function into the rgdal package.
> >>> However It looks like I have a problem of supported formats
> >>> (dataset object of SpatialGridDataFrame-class or SpatialPixelsDataFrame-class
> >>> ) that is not the same as the one resulting from my krige.conv function
> >>> (kriging -class apparently)
> >>>
> >>> I tried several function to achieve this conversion (getRasterData,
> >>> SpatialGridDataFrame, SpatialPixelsDataFrame, create2GDAL, points2grid...).
> >>> But without any success.
> >>>
> >>> #my actual kriging script:
> >>> pred.grid = expand.grid(seq(170000, 130000, l = 50), seq(190000, 160000, l =
> >>> 50))
> >>>
> >> library(sp)
> >> pred.grid$var3 <- 1
> >> coordinates(pred.grid) <- c("Var1", "Var2")
> >> gridded(pred.grid) <- TRUE
> >>
> >> # Create a SpatialPixelsDataFrame or SpatialGridDataFrame object first
> >> # - forced here by including a non-coordnate column to the data frame
> >>
> >>
> >>> myPred = krige.conv(myGData, loc = pred.grid, krige = krige.control(obj.m =
> >>> myOLSMod))
> >>>
> >> myPred = krige.conv(myGData, loc = coordinates(pred.grid),
> >>   krige = krige.control(obj.m = myOLSMod))
> >>
> >> # Krige with the coordinates of the object
> >>
> >> pred.grid$predict <- myPred$predict
> >>
> >> # add the predictions (and standard errors if you like) to the
> >> # object, they are in the correct order;
> >> # then write out, choosing the output column as desired
> >>
> >> tf <- tempfile()
> >> writeGDAL(pred.grid["predict"], tf, drivername="GTiff") # not type="Byte"!
> >> GDALinfo(tf)
> >>
> >> # I suppose you are using the temporary file here to test your approach
> >> # as you ought to put the output file in a permanent place if you will
> >> # need it later
> >>
> >> Hope this helps,
> >>
> >> Roger
> >>
> >>
> >>> image(myPred, loc = pred.grid, col = gray(seq(1, 0.1, l = 30)))
> >>>
> >>> #my conversion attempts
> >>> tf <- tempfile()
> >>> writeGDAL(myPred, tf, drivername="GTiff", type="Byte", options=NULL)
> >>> [Erreur dans function (classes, fdef, mtable) : unable to find an inherited
> >>> method for function "gridded", for signature "kriging"]
> >>>
> >>> Thanks a lot,
> >>>
> >>> Nicolas
> >>>
> >>> _______________________________________________
> >>> R-sig-Geo mailing list
> >>> R-sig-Geo at stat.math.ethz.ch
> >>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >>>
> >>>
> >> --
> >> Roger Bivand
> >> Economic Geography Section, Department of Economics, Norwegian School of
> >> Economics and Business Administration, Helleveien 30, N-5045 Bergen,
> >> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
> >> e-mail: Roger.Bivand at nhh.no
> >>
> >> _______________________________________________
> >> R-sig-Geo mailing list
> >> R-sig-Geo at stat.math.ethz.ch
> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >>
> >>
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo at stat.math.ethz.ch
> > 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.springer.com/978-0-387-78170-9 e.pebesma at wwu.de
>
>




More information about the R-sig-Geo mailing list