require(splancs)
data(bodmin)
x= kernel2d(as.points(bodmin), bodmin$poly, h0=2, nx=100, ny=100)
require(sp)
g=expand.grid(x$x,x$y,x$z)
The last line gives the following error:
Error: cannot allocate vector of size 390625 Kb
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.