Dear list members,

     I'm trying to extract a pixel values in regular grid on a krigging 
object create with geoR package. But I don't' have success in convert 
the krigging object in SpatialPixelsDataFrame, in my example:

#

require(geoR)

require(sp)

require(raster)

plot(s100$coords, xlim=c(0,1.2), ylim=c(0,1.2), xlab="Coord X", 
ylab="Coord Y")

loci <- matrix(c(0.2, 0.6, 0.2, 1.1, 0.2, 0.3, 1.0, 1.1), ncol=2)

text(loci, as.character(1:4), col="red")

polygon(x=c(0,1,1,0), y=c(0,0,1,1), lty=2)

# Fitting models with nugget fixed to zero

ml <- likfit(s100, ini = c(1,0.5), fix.nugget = T)

# defining the grid

pred.grid <-expand.grid(seq(0,1, l=51), seq(0,1, l=51))

# kriging calculations

kc <- krige.conv(s100, loc = pred.grid, krige = krige.control(obj.m = ml))

# displaying predicted values

image(kc, loc = pred.grid, col=gray(seq(1,0.1,l=30)), xlab="Coord X", 
ylab="Coord Y")

#

#Center of 25 samples with 0.2 x 0.2

p0<-c(0.1,0.1) ## 1^st coordinate

# Create a grid

c0 <- seq(p0[1],p0[1]+0.9,by=0.2)

d0 <- seq(p0[2],p0[2]+0.9,by=0.2)

d1 <- expand.grid(x=c0, y=d0)

points(d1[,1],d1[,2],col="red")

# Draw the samples

grid=GridTopology(c(0.1,0.1), c(0.2,0.2), c(5,5))

grid=SpatialGrid(grid=grid)

class(grid)## SpatialPixels

gridPol <- as(grid, "SpatialPolygons")

coordinates(pred.grid) <- ~ Var1+Var2## Grid coordinates

kc$predict<-as.data.frame(kc$predict)### Value of prediction grid

kc_output<-SpatialPixelsDataFrame(points=pred.grid, data=kc$predict)### 
SpatialPixelsDataFrame object

z<-extract(over(kc_output, grid)) #Pixels values in each sample


              I ask, if there are any solution for make this?
Thanks
     --
     Alexandre dos Santos
     Forest entomology
     IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato 
Grosso


	[[alternative HTML version deleted]]

