[R-sig-Geo] search,grids,SA significance test

Trevor Doerksen trevor.doerksen at gmail.com
Tue Feb 27 18:07:46 CET 2007


Hi,

I'm new to the mailing list and I see there is a large repository of 
info in the archives. Is there any way to search it, to find answers to 
my potentially redundant questions?

I have some training in IDRISI's GIS and have used R for just over a 
year. I've started using the gstat package in R and worked through some 
of the excellent examples in 1) Pebesma and Bivand. 2005. S classes and 
methods for spatial data: the sp package.  2) Pebesma. 2006. The meuse 
data set: a tutorial for gstat R package. 3) Pebesma. 2004. 
Multivariable geostatistics in S: the gstat package. Computers & 
Geosciences. 30:683-691.

I have two specific questions:
1) I'm having trouble creating a grid of regularly spaced points that 
gstat will accept for use with the krige function. Also, I don't know 
how to mask a specific area (like the nice grid in the meuse data set) 
of interest within that grid. Does anyone have examples/references not 
listed above? Below is one attempt at some code which didn't work. NOTE: 
My samples are irregularly spaced and I don't need predictions over the 
entire rectangular grid.

#FIRST attempt
x=seq(246000,606000,1000)
length(x)    #361
y=seq(4851000,5084000,1000)
length(y)    #234
pts.4.grd=expand.grid(x,y)    # resolution = 1km^2; size = 361*234 = 84474
names(pts.4.grd)=c('x','y')
str(pts.4.grd)    # dataframe
grd.pts = SpatialPixels(SpatialPoints(pts.4.grd))
str(grd.pts)    #SpatialPixels
grd = as(grd.pts, "SpatialGrid")
str(grd)    #X=Var1, Y=Var2

# variogram fit not shown. Trying 'universal kriging', with a N-S trend 
removed.
kr1.f2.v2=krige(bv~UTMN83+UTMN83*UTMN83,locations=~UTME83+UTMN83,data=all,grd,model=fit2.v2)
#doesn't work with the following error. Grid and sample data not same size?
#Error in gstat.formula.predict(d$formula, newdata, na.action = 
na.action) :
#        NROW(locs) != NROW(X): this should not occur
#In addition: Warning messages:
#1: 'newdata' had 84474 rows but variable(s) found have 440 rows
#2: 'newdata' had 84474 rows but variable(s) found have 440 rows

2) Is there a test to compute the significance of spatial 
autocorrelation in a variogram? The biological signal I'm modelling in 
my variograms is very weak, with a huge nugget. How large can the nugget 
be before it negates the spatially specific weights for kriging, thus 
rendering the prediction close to an inverse distance weighting scheme?

Thanks,

Trevor.




More information about the R-sig-Geo mailing list