# \donttest{
library(terra)
lsat <- rast(system.file("/extdata/Landsat_TM5.tif", package="spatialEco"))
# Using Modified Soil-adjusted Vegetation Index (MSAVI)
( wmsavi <- swvi(red = lsat[[3]], nir = lsat[[4]], swir = lsat[[5]]) )
plotRGB(lsat, r=6,g=5,b=2, scale=1, stretch="lin")
plot(wmsavi, legend=FALSE, col=rev(terrain.colors(100, alpha=0.35)), add=TRUE )
# Using Modified Triangular Vegetation Index 2 (MTVI)
( wmtvi <- swvi(red = lsat[[3]], nir = lsat[[4]], swir = lsat[[5]],
green = lsat[[3]], mtvi = TRUE) )
plotRGB(lsat, r=6,g=5,b=2, scale=1, stretch="lin")
plot(wmtvi, legend=FALSE, col=rev(terrain.colors(100, alpha=0.35)), add=TRUE )
# }
Run the code above in your browser using DataLab