mosaic_index2 | R Documentation |
Compute or extract an index layer from a multi-band mosaic raster using gdal_calc.py (https://gdal.org/programs/gdal_calc.html). This requires a Python and GDAL installation.
mosaic_index2(
mosaic,
index = "B",
r = 3,
g = 2,
b = 1,
re = 4,
nir = 5,
plot = TRUE,
python = Sys.which("python.exe"),
gdal = Sys.which("gdal_calc.py")
)
mosaic |
A mosaic of class |
index |
A character value (or a vector of characters) specifying the
target mode for conversion to a binary image. Use |
r , g , b , re , nir |
The red, green, blue, red-edge, and near-infrared bands of the image, respectively. By default, the function assumes a BGR as input (b = 1, g = 2, r = 3). If a multispectral image is provided up to seven bands can be used to compute built-in indexes. There are no limitation of band numbers if the index is computed using the band name. |
plot |
Plot the computed index? Defaults to |
python |
The PATH for python.exe |
gdal |
The PATH for gdal_calc.py |
An index layer extracted/computed from the mosaic raster.
if((Sys.which('python.exe') != '' ) & (Sys.which('gdal_calc.py') != '' )){
library(pliman)
mosaic <- mosaic_input(system.file("ex/elev.tif", package="terra"))
names(mosaic) <- "R"
elev2 <- mosaic_index2(mosaic, "R * 5", plot = FALSE)
oldpar <- par(no.readonly=TRUE)
mosaic_plot(mosaic)
mosaic_plot(elev2)
par(mfrow=c(1,2))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.