
spmap.to.lev(data, zcol = 1:n, n = 2, names.attr)
## S3 method for class 'SpatialPointsDataFrame':
stack(x, select, ...)
## S3 method for class 'SpatialGridDataFrame':
stack(x, select, ...)
zcol
data
zcol
spmap.to.lev
returns a data frame with the following elements:zcol
of data
stackedz
columnsstack
is an S3 method: it return a data.frame with a column
values
that has the stacked coordinates and attributes, and a
column ind
that indicates the variable stacked; it also
replicates the coordinates.lattice
, and stacklibrary(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, spmap.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, spmap.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")
Run the code above in your browser using DataLab