Make a Red-Green-Blue plot based on three layers (in a RasterBrick or RasterStack).
Three layers (sometimes referred to as "bands" because they may represent
different bandwidths in the electromagnetic spectrum) are combined such
that they represent the red, green and blue channel. This function can
be used to make 'true (or false) color images' from Landsat and other
multi-band satellite images. Note, this text is plagirized, i.e. copied
from plotRGB
.
# S4 method for RasterStackBrick
viewRGB(x, r = 3, g = 2, b = 1,
quantiles = c(0.02, 0.98), map = NULL,
maxpixels = mapviewGetOption("mapview.maxpixels"),
map.types = mapviewGetOption("basemaps"),
na.color = mapviewGetOption("na.color"),
layer.name = deparse(substitute(x, env = parent.frame())), ...)
a RasterBrick or RasterStack
integer. Index of the Red channel, between 1 and nlayers(x)
integer. Index of the Green channel, between 1 and nlayers(x)
integer. Index of the Blue channel, between 1 and nlayers(x)
the upper and lower quantiles used for color stretching
the map to which the layer should be added
integer > 0. Maximum number of cells to use for the plot.
If maxpixels < ncell(x)
, sampleRegular is used before plotting.
character spcifications for the base maps. see http://leaflet-extras.github.io/leaflet-providers/preview/ for available options.
the color to be used for NA pixels
the name of the layer to be shown on the map
additional arguments passed on to mapView
library(raster)
viewRGB(poppendorf, 4, 3, 2) # true-color
viewRGB(poppendorf, 5, 4, 3) # false-color
Run the code above in your browser using DataLab