gplot-methods: Use ggplot to plot a Raster* object

Description Usage Arguments Author(s) See Also Examples

Description

A wrapper function around ggplot (ggplot2 package). Note that the function in the raster package is called gplot with a single 'g'.

Usage

1
2
## S4 method for signature 'Raster'
gplot(x, maxpixels=50000,...) 

Arguments

x

A Raster* object

maxpixels

Maximum number of pixels to use

...

Additional arguments for ggplot

Author(s)

Robert J. Hijmans and Oscar Perpiñán; based on an example by Paul Hiemstra

See Also

plot, spplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
 
## Not run: 
r <- raster(system.file("external/test.grd", package="raster"))
s <- stack(r, r*2)
names(s) <- c('meuse', 'meuse x 2')

library(ggplot2)

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

## End(Not run)

rasterVis documentation built on May 2, 2019, 6:49 p.m.