I have the output of an interp() in "standard" list form:

ie: "x", "y", "z", where x is a vector of longs, y is a vector of lats, z is
a (x-1 x y-1) matrix of depth values

which I would like to coerce to SpatialGridDataFrame so that I can export it
to an external GIS via writeGDAL(), but I am struggling with understanding
how to do this...

d <- interp(...)

cells.dim <- c(dim(d$z)[1], dim(d$y)[2])
dx <- diff(d$x[2:1])
dy <- diff(d$y[2:1])
cellsize <- c(dx, dy)
cc.offset <- c(min(d$x) + dx/2, min(d$y) + dy/2)

gt <- GridTopology(cc.offset, cellsize, cells.dim)

## Is this a viable (preferable?) alternative path to gt, btw?
## pts <- expand.grid(x = d$x, y = d$y)
## gt <- SpatialPixels(pts)

SpatialGrid(gt)

and here I am stuck. How do I associate the matrix d$z with the SpatialGrid?

(I think that an alternative solution, which I would also be interested in
learning, would be to perform the krig directly on a SpatialPointsDataFrame
object.)

Any advice appreciated.

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to