#Instalar paquete raster
#install.packages("raster")
#Instalar paquete sp
#install.packages("sp")
#Instalar paquete rgdal
#install.packages("rgdal")
#Paquetes instalados
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-27, (SVN revision 1148)
## 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/ASUS/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/ASUS/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/ASUS/Documents/R/win-library/4.1/rgdal/proj
#Instalar los objetos a mis variables
b2 <-raster("C:/Users/ASUS/Downloads/IMAGENESBANDAS/LC08_L1TP_008058_20210917_20210917_02_RT/LC08_L1TP_008058_20210917_20210917_02_RT_B2.tif")
b3 <-raster("C:/Users/ASUS/Downloads/IMAGENESBANDAS/LC08_L1TP_008058_20210917_20210917_02_RT/LC08_L1TP_008058_20210917_20210917_02_RT_B3.tif")
b4 <-raster("C:/Users/ASUS/Downloads/IMAGENESBANDAS/LC08_L1TP_008058_20210917_20210917_02_RT/LC08_L1TP_008058_20210917_20210917_02_RT_B4.tif")
b5 <-raster("C:/Users/ASUS/Downloads/IMAGENESBANDAS/LC08_L1TP_008058_20210917_20210917_02_RT/LC08_L1TP_008058_20210917_20210917_02_RT_B5.tif")
b6 <-raster("C:/Users/ASUS/Downloads/IMAGENESBANDAS/LC08_L1TP_008058_20210917_20210917_02_RT/LC08_L1TP_008058_20210917_20210917_02_RT_B6.tif")
b7 <-raster("C:/Users/ASUS/Downloads/IMAGENESBANDAS/LC08_L1TP_008058_20210917_20210917_02_RT/LC08_L1TP_008058_20210917_20210917_02_RT_B7.tif")
#Revision
b4
## class : RasterLayer
## dimensions : 7731, 7581, 58608711 (nrow, ncol, ncell)
## resolution : 30, 30 (x, y)
## extent : 411585, 639015, 203385, 435315 (xmin, xmax, ymin, ymax)
## crs : +proj=utm +zone=18 +datum=WGS84 +units=m +no_defs
## source : LC08_L1TP_008058_20210917_20210917_02_RT_B4.TIF
## names : LC08_L1TP_008058_20210917_20210917_02_RT_B4
## values : 0, 65535 (min, max)
crs(b4)
## CRS arguments:
## +proj=utm +zone=18 +datum=WGS84 +units=m +no_defs
#Ploteo de bandas
plot(b2)

#Ploteo de bandas
par(mfrow = c(2,2))
plot(b2, main="blue", col = gray(0:10/10))
plot(b3, main="green", col = gray(0:10/10))
plot(b4, main="red", col = gray(0:10/10))
plot(b5, main="infrared", col = gray(0:10/10))

#Plotear mi color verdadero
landsatRGB <-stack(b4, b3, b2)
plotRGB(landsatRGB, stretch = "lin", main = "Color verdadero")
