Learn R Programming

raster (version 1.8-39)

spplot: Use spplot or ggplot to plot a Raster* object

Description

These are simple wrapper functions around spplot (sp package) and ggplot (ggplot2 package), allowing for attractive mapping of Raster objects. For example, with spplot it is easy to map several layers with a single legend for all maps. ssplot is a wrapper around the levelplot function in the lattice package, and see the help for these functions for additional options. Note that the function in the raster package is called gplot with a single 'g'. One of the advantages of these wrapper functions is the additional maxpixels argument to sample large Raster objects for faster drawing.

Usage

gplot(x, ...)

Arguments

x
A Raster* object
...
Additional arguments. See under Details

Methods

spplot(obj, ..., maxpixels=50000, as.table=TRUE) gplot(x, maxpixels=50000, ...) rll{ obj A Raster* object ... Any argument that can be passed to spplot and link[lattice]{levelplot} or to ggplot maxpixels Integer. Number of pixels to sample from each layer of large Raster objects }

See Also

plot, plot3D, plotRGB

Examples

Run this code
r <- raster(system.file("external/test.grd", package="raster"))
s <- stack(r, r*2)
layerNames(s) <- c('meuse', 'meuse x 2')

spplot(s)

if (require(ggplot2)) {
  theme_set(theme_bw())
  gplot(s) + geom_tile(aes(fill = value)) + facet_wrap(~ variable) +
            scale_fill_gradient(low = 'white', high = 'blue') + coord_equal()
}

Run the code above in your browser using DataLab