Hello,

I am trying to do some Kriging incorporating a gradient trend in the data (i.e.  krige(log(zinc)~sqrt(dist),...) based on the method described in http://r-spatial.sourceforge.net/gallery/ and Bivand's book. I have been having problems with producing the appropriate grid with a format that incorporates distance. Just to make sure there are no errors in my own data I have utilised the "meuse" dataset and adapted the example in http://r-spatial.sourceforge.net/gallery/.

In the meuse dataset the grid is loaded with the data(meuse.grid). But I can't find a way that recreates the same data with the original meuse dataset. I have tried the following:

meuse.grid = spsample(meuse, type = "regular", cellsize = c(50,50))
gridded(meuse.grid) = TRUE

and

meuse.grid <-SpatialPixels(SpatialPoints(makegrid(meuse)))
gridded(meuse.grid) = TRUE

Neither of the above methods work when I use a Kriging function that incorporates distance (log(zinc)~sqrt(dist)). However they work if I use ordinary kriging with the function zinc~1. I also noticed that meuse.grid includes distance measurements.

CODE
====================

library(sp)
library(gstat)

data(meuse)
coordinates(meuse)=~x+y

#Original Method - only method that works
data(meuse.grid)
data_grid<-meuse.grid
coordinates(data_grid) = ~x+y
gridded(data_grid) = TRUE

#Method 2 - does not work
#data_grid = spsample(meuse, type = "regular", cellsize = c(50,50))
#gridded(data_grid) = TRUE

#Method 3 - does not work
#data_grid<-SpatialPixels(SpatialPoints(makegrid(meuse)))
#gridded(data_grid) = TRUE

v.uk = variogram(log(zinc)~sqrt(dist), meuse)
uk.model = fit.variogram(v.uk, vgm(1, "Exp", 300, 1))

zn.uk = krige(log(zinc)~sqrt(dist), meuse, data_grid, model = uk.model)

print(spplot(zn.uk, "var1.pred"))

=========================

Thanks for the help,

Alex Lechner

Research Fellow
Centre for Mined Land Rehabilitation
Sustainable Minerals Institute
University of Queensland

	[[alternative HTML version deleted]]

