A correction (due to grid orientation), with example:

library(rgdal)
d <- list(x  =1:10, y = 2:11, z = matrix(1:100, 10, 10))
gt <- GridTopology(cellcentre.offset = c(d$x[1], d$x[2]), 
    cellsize = c(diff(d$x[1:2])/2, diff(d$y[1:2])/2), cells.dim = dim(d$z))

 ## because of the way the grids are oriented compared to the normal R image
 grd.atts <- SpatialGridDataFrame(gt, list(depth =
as.vector(d$z[,ncol(d$z):1])))


