Skip to content
Prev 844 / 29559 Next

SpatialGrid from matrix

You are expanding your grid for every cell in the matrix, per every grid 
location - which *really is* a lot of memory.  You really want something 
like this:

g <- cbind(expand.grid(x = x$x, y = x$y), as.vector(x$z))
coordinates(g) <- c("x", "y")
gridded(g) <- TRUE
image(g)
contour(x, add = T)  ## just to be sure

I'm pretty sure the ordering is right for this case, but be sure to check.

Cheers, Mike.