im.plotRGB {imageRy}R Documentation

Plot a Raster Image as an RGB Composite with User-Selected Bands

Description

This function visualizes a multispectral raster image using user-defined bands for the Red, Green, and Blue channels. A linear contrast stretch is applied to enhance visualization.

Usage

im.plotRGB(x, r, g, b, title = "")

Arguments

x

A 'SpatRaster' object representing the input multispectral image.

r

An integer specifying the band index for the Red channel.

g

An integer specifying the band index for the Green channel.

b

An integer specifying the band index for the Blue channel.

title

A character string specifying the plot title (default: "").

Details

- The function allows users to **manually select bands** for RGB visualization. - It applies 'stretch="lin"' in 'plotRGB()' to enhance contrast. - Axis and label colors are set to white for better contrast with dark backgrounds. - The function supports displaying axes ('axes = TRUE') and sets plot margins.

Value

This function does not return an object. It directly generates a plot.

See Also

[im.plotRGB.auto()], [im.ggplot()]

Examples

library(terra)

# Create a 3-band raster
r <- rast(nrows = 10, ncols = 10, nlyrs = 3)
values(r) <- runif(ncell(r) * 3)

# Plot with user-selected bands (3 = Red, 2 = Green, 1 = Blue)
im.plotRGB(r, r = 3, g = 2, b = 1, title = "Custom RGB Visualization")

[Package imageRy version 0.3.0 Index]