[R-sig-Geo] Example of universal kriging with R/gstat in GRASS needed

Roger Bivand Roger.Bivand at nhh.no
Thu Apr 27 22:21:55 CEST 2006


On Thu, 27 Apr 2006, Thomas Adams wrote:

> List:
> 
> I can not seem to work out the syntax for using R/gstat within a GRASS 
> 6.1 session to do universal kriging. I have a DEM (elevation data on a 
> grid) and point data for temperature; theoretically, the temperatures 
> should relate to elevation. So, I am trying to spatially interpolate the 
> temperature data based on the elevations at the grid points. How do I 
> setup the gstat command in R/gstat (and using spgrass6, of course)? I 
> have no trouble reading in my elevation data (DEM) from GRASS and I have 
> no problem doing ordinary kriging of my temperature data using 
> GRASS/R/gstat.

What do the data look like? Do you have temperature and elevation at the
observation points and elevation over the grid? If temperature is the 
variable for which you want to interpolate, then the formula argument in 
the gstat() function would be temp ~ elev, data=pointsdata (if a 
SpatialPointsDataFrame no need for location= ~ x + y). Then the predict() 
step would need a SpatialGridDataFrame object as newdata, with elev as 
(one of) the columns in the data slot.

An example for the Meuse bank data in Burrough and McDonnell:

cvgm <- variogram(Zn ~ Fldf, data=BMcD, width=100, cutoff=1000)
uefitted <- fit.variogram(cvgm, vgm(psill=1, model="Exp", range=100, 
  nugget=1))
UK_fit <- gstat(id="UK_fit", formula = Zn ~ Fldf, data = BMcD, 
  model=uefitted)
z <- predict(UK_fit, newdata=BMcD_SPx)

where BMcD_SPx is a SpatialPixelsDataFrame (the grid has ragged edges) 
with flood frequencies in Fldf (actually a factor, but works neatly).

Hope this helps,

Roger

> 
> Regards,
> Tom
> 
> 

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




More information about the R-sig-Geo mailing list