** INDICE DE VEGETACION DIFERENCIA NORMALIZADA
Se utiliza para estimar la cantidad, calidad y desarrollo de la vegetación
*** SOLUCION PRACTICA
# INTALAR PAQUETES
#install.packages("sp")
#install.packages("raster")
#install.packages("rgdal")
# LLAMAR PAQUETES
library (sp)
library (raster)
library(rgdal)
## Please note that rgdal will be retired by the end of 2023,
## plan transition to sf/stars/terra functions using GDAL and PROJ
## at your earliest convenience.
##
## rgdal: version: 1.5-25, (SVN revision 1143)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.2.1, released 2020/12/29
## Path to GDAL shared files: C:/Users/PC/Documents/R/win-library/4.1/rgdal/gdal
## GDAL binary built with GEOS: TRUE
## Loaded PROJ runtime: Rel. 7.2.1, January 1st, 2021, [PJ_VERSION: 721]
## Path to PROJ shared files: C:/Users/PC/Documents/R/win-library/4.1/rgdal/proj
## PROJ CDN enabled: FALSE
## Linking to sp version:1.4-5
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
## Overwritten PROJ_LIB was C:/Users/PC/Documents/R/win-library/4.1/rgdal/proj
SELECCIONAR LAS BANDAS
B2<-raster("C:/Users/PC/Desktop/SEMESTRE 2021-2/CRISTIAN_E2/rs/LC08_044034_20170614_B2.tif")
B3<-raster("C:/Users/PC/Desktop/SEMESTRE 2021-2/CRISTIAN_E2/rs/LC08_044034_20170614_B3.tif")
B4<-raster("C:/Users/PC/Desktop/SEMESTRE 2021-2/CRISTIAN_E2/rs/LC08_044034_20170614_B4.tif")
B5<-raster("C:/Users/PC/Desktop/SEMESTRE 2021-2/CRISTIAN_E2/rs/LC08_044034_20170614_B5.tif")
B6<-raster("C:/Users/PC/Desktop/SEMESTRE 2021-2/CRISTIAN_E2/rs/LC08_044034_20170614_B6.tif")
INFORMACION DE LAS BANDAS A UTILIZAR
B4 #RED
## class : RasterLayer
## dimensions : 1245, 1497, 1863765 (nrow, ncol, ncell)
## resolution : 30, 30 (x, y)
## extent : 594090, 639000, 4190190, 4227540 (xmin, xmax, ymin, ymax)
## crs : +proj=utm +zone=10 +datum=WGS84 +units=m +no_defs
## source : LC08_044034_20170614_B4.tif
## names : LC08_044034_20170614_B4
## values : 0.02084067, 0.7861769 (min, max)
B5 #NIR
## class : RasterLayer
## dimensions : 1245, 1497, 1863765 (nrow, ncol, ncell)
## resolution : 30, 30 (x, y)
## extent : 594090, 639000, 4190190, 4227540 (xmin, xmax, ymin, ymax)
## crs : +proj=utm +zone=10 +datum=WGS84 +units=m +no_defs
## source : LC08_044034_20170614_B5.tif
## names : LC08_044034_20170614_B5
## values : 0.0008457669, 1.012432 (min, max)
PLOTER DE LAS BANDAS A USAR
# BANDA B4
plot(B4, main="Red", col = gray (0:100/100))
# BANDA B5
plot(B5, main="NIR", col = gray (0:100/100))
COLORE VERDADERO
# PLOTEAR A COLOR VERDADERO
LandsatRGB <- stack(B4, B3, B2)
GRAFICA
plotRGB(LandsatRGB, axes= TRUE, stretch ="hist", main = "color verdadero")
CALCULO DEL INDICE NDVI
IMAGEN <- stack(B4, B5)
NDVI= ((B5-B4)/(B5+B4))
MOSTAR IMAGEN
plot(NDVI)
plot(NDVI, axes= TRUE, main="NDVI")