### Name: stack
### Title: rearrange data in SpatialPointsDataFrame or SpatialGridDataFrame
###   for plotting with spplot (levelplot/xyplot wrapper)
### Aliases: map.to.lev stack.SpatialPointsDataFrame
###   stack.SpatialGridDataFrame
### Keywords: dplot

### ** Examples

library(lattice)
data(meuse.grid) # data frame
coordinates(meuse.grid) = c("x", "y") # promotes to SpatialDataFrame
meuse.grid[["idist"]] = 1 - meuse.grid[["dist"]] # add variable
# the following is made much easier by spplot:
levelplot(z~x+y|name, map.to.lev(meuse.grid, z=c("dist","idist"), names.attr =
        c("distance", "inverse of distance")), aspect = "iso")
levelplot(values~x+y|ind, as.data.frame(stack(meuse.grid)),aspect = "iso")
gridded(meuse.grid) = TRUE
levelplot(z~x+y|name, map.to.lev(meuse.grid, z=c("dist","idist"), names.attr =
        c("distance", "inverse of distance")), aspect = "iso")
levelplot(values~x+y|ind, as.data.frame(stack(meuse.grid)), asp = "iso")




