varRGB: Generate an RGB image from 3 spectral bands

Description Usage Arguments Details Examples

View source: R/varRGB.R

Description

varRGB creates red-green-blue (RGB) images as a RasterStack by scaling the pixel values to 0-255 color range.

Usage

1
varRGB(red, green, blue, q.range = c(), rPath = NULL, region = NULL)

Arguments

red

a raster with the red band of the capture.

green

a raster with the green band of the capture.

blue

a raster with the blue band of the capture.

q.range

a vector with the minimum and maximum reflectance quantiles being considered.

rPath

the file path where the resulting RGB image is saved.

region

a Spatial*, projected raster*, or sf class object defining the area of interest for image masking.

Details

The function rescales the original reflectance values to a range of 0-255. The function re-arranges the RGB bands to create a stack ready to visualize with plotRGB. Bands may contain outliers which cause the image to look dark. Use the q.range argument to remove the outliers and get a better-looking image.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# path to the cropped and cutted MODIS images for the region of Navarre
wdir <- system.file("ExNavarreVar", package = "RGISTools")
# list all the tif files
files.mod <- list.files(wdir, pattern="\\.tif$", recursive = TRUE, full.names = TRUE)
# print the MOD09 bands
getRGISToolsOpt("MOD09BANDS")

# select the red, blue and NIR bands
img.mod.red <- raster(files.mod[1])
img.mod.blue <- raster(files.mod[3])
img.mod.green <- raster(files.mod[4])

q.range=c(0.001,0.999)
img.mod.rgb<-varRGB(img.mod.red,img.mod.green,img.mod.blue,q.range)
print(plotRGB(img.mod.rgb))

RGISTools documentation built on July 2, 2020, 3:58 a.m.