mosaic_to_rgb | R Documentation |
Convert an SpatRaster
to a three-band RGB image of class Image
.
mosaic_to_rgb(mosaic, r = 3, g = 2, b = 1, coef = 0, plot = TRUE)
mosaic |
A mosaic of class |
r |
The layer for the Red band (default: 3). |
g |
The layer for the Green band (default: 2). |
b |
The layer for the Blue band (default: 1). |
coef |
An addition coefficient applied to the resulting object. This is useful to adjust the brightness of the final image. Defaults to 0. |
plot |
Logical, whether to display the resulting RGB image (default: TRUE). |
This function converts SpatRaster
that contains the RGB bands into
a three-band RGB image using pliman (EBImage). It allows you to specify the
band indices for the red, green, and blue channels, as well as apply a
scaling coefficient to the final image. By default, the resulting RGB image
is displayed, but this behavior can be controlled using the plot
parameter.
A three-band RGB image represented as a pliman (EBImage) object.
library(pliman)
# Convert a mosaic raster to an RGB image and display it
mosaic <- mosaic_input(system.file("ex/elev.tif", package="terra"))
# Convert a mosaic raster to an RGB image without displaying it
rgb_image <- mosaic_to_rgb(c(mosaic * 2, mosaic - 0.3, mosaic * 0.8))
plot(rgb_image)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.