stack

0th

Percentile

rearrange data in SpatialPointsDataFrame or SpatialGridDataFrame for plotting with spplot (levelplot/xyplot wrapper)

rearrange SpatialPointsDataFrame for plotting with spplot or levelplot

Keywords
dplot
Usage
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, ...)
Arguments
data
object of class (or extending) SpatialPointsDataFrame or SpatialGridDataFrame
zcol
z-coordinate column name(s), or a column number (range) (after removing the spatial coordinate columns: 1 refers to the first non-coordinate column, etc. )
names.attr
names of the set of z-columns (these names will appear in the plot); if omitted, column names of zcol
n
number of columns to be stacked
x
same as data
select
same as zcol
...
ignored
Value

  • spmap.to.lev returns a data frame with the following elements:
  • xx-coordinate for each row
  • yy-coordinate for each row
  • zcolumn vector with each of the elements in columns zcol of data stacked
  • namefactor; name of each of the stacked z columns
  • stack 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.

See Also

spplot, levelplot in package lattice, and stack

Aliases
  • spmap.to.lev
  • stack.SpatialPointsDataFrame
  • stack.SpatialGridDataFrame
Examples
library(lattice)
data(meuse.grid) # data frame
coordinates(meuse.grid) = c("x", "y") # promotes to SpatialPointsDataFrame
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")
Documentation reproduced from package sp, version 0.9-94, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.