plotRGB | R Documentation |
Make a Red-Green-Blue plot based on three layers in a SpatRaster. The 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-spectral satellite images.
Note that the margins of the plot are set to zero (no axes or titles are visible) but can be set with the mar
argument.
An alternative way to plot RGB images is to first use colorize
to create a single layer SpatRaster with a color-table and then use plot
.
## S4 method for signature 'SpatRaster'
plotRGB(x, r=1, g=2, b=3, a=NULL, scale=NULL, mar=0,
stretch=NULL, smooth=TRUE, colNA="white", alpha=NULL, bgalpha=NULL,
zlim=NULL, zcol=FALSE, axes=FALSE ,...)
x |
SpatRaster |
r |
integer between 1 and |
g |
integer between 1 and |
b |
integer between 1 and |
a |
NULL or integer between 1 and |
scale |
integer. Maximum (possible) value in the three channels. Defaults to 255 or to the maximum value of |
mar |
numeric vector recycled to length 4 to set the margins of the plot. Use |
stretch |
character. Option to stretch the values to increase contrast: "lin" (linear) or "hist" (histogram). The linear stretch uses |
smooth |
logical. If |
colNA |
color. The color used for cells that have NA values |
alpha |
transparency. Integer between 0 (transparent) and 255 (opaque) |
bgalpha |
Background transparency. Integer between 0 (transparent) and 255 (opaque) |
zlim |
numeric vector of length 2. Range of values to plot (optional). If this is set, and |
zcol |
logical. If |
axes |
logical. If |
... |
graphical parameters as in |
plot
, colorize
, RGB
b <- rast(system.file("ex/logo.tif", package="terra"))
plotRGB(b)
plotRGB(b, mar=2)
plotRGB(b, 3, 2, 1)
b[1000:2000] <- NA
plotRGB(b, 3, 2, 1, stretch="hist")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.