library(terra)
## terra 1.7.65
f <- "C:\\Users\\pd557\\Downloads\\Img_Example.tif"
Img_Example <- rast(f)
plotRGB(Img_Example, r=3, g=2, b=1, stretch="lin")

BandNIR <- Img_Example[[4]]
plot(Img_Example[[4]])

BandRED <- Img_Example[[1]]
plot(Img_Example[[1]])

x <- BandNIR-BandRED
y <- BandNIR+BandRED
x/y
## class : SpatRaster
## dimensions : 3368, 6034, 1 (nrow, ncol, nlyr)
## resolution : 3, 3 (x, y)
## extent : 372207, 390309, 3861684, 3871788 (xmin, xmax, ymin, ymax)
## coord. ref. : WGS 84 / UTM zone 14N (EPSG:32614)
## source(s) : memory
## varname : Img_Example
## name : Img_Example_4
## min value : -0.004587156
## max value : 0.945903444
plot(x/y)
