ggRGB: RGB spatial plot with ggplot

Description Usage Arguments Author(s) Examples

View source: R/ggRGB.R

Description

Produces an object to feed into ggplot geom_raster or geom_tile to produce a rgb plot

Usage

1
ggRGB(x, r, g, b)

Arguments

x

RasterStackBrick object

r

Numeric Band number to be plotted in red

g

Numeric Band number to be plotted in green

b

Numeric Band number to be plotted in blue

Author(s)

Loic Dutrieux (using some code snippets by Josh Gray and Robert Hijmans)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(ggplot2)
library(raster)

x <- brick(system.file("external/rlogo.grd", package="raster"))

ggrgb <- ggRGB(x, 3,2,1)

ggplot() +
    geom_raster(data = ggrgb, aes(x=x, y=y, fill=values)) +
    scale_fill_identity() +
    coord_equal() +
    scale_x_continuous(name = 'Lat', expand=c(0, 0)) +
    scale_y_continuous(name = 'Long', expand=c(0, 0))

loicdtx/ggSpatial documentation built on May 21, 2019, 7:37 a.m.