#install.packages("raster")
#install.packages("sp")
#install.packages("rgdal")
library(rgdal)
## Loading required package: sp
## 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/USUARIO/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/USUARIO/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/USUARIO/Documents/R/win-library/4.1/rgdal/proj
library (sp)
library (raster)
#Asignar los objetos a mis variables
B1 <-raster("C:/Users/USUARIO/Documents/A02/LC08_L1TP_008058_20210528_20210607_02_T1_B1.TIF")
B2 <-raster("C:/Users/USUARIO/Documents/A02/LC08_L1TP_008058_20210528_20210607_02_T1_B2.TIF")
B3 <-raster("C:/Users/USUARIO/Documents/A02/LC08_L1TP_008058_20210528_20210607_02_T1_B3.TIF")
B4 <-raster("C:/Users/USUARIO/Documents/A02/LC08_L1TP_008058_20210528_20210607_02_T1_B4.TIF")
B5 <-raster("C:/Users/USUARIO/Documents/A02/LC08_L1TP_008058_20210528_20210607_02_T1_B5.TIF")
B6 <-raster("C:/Users/USUARIO/Documents/A02/LC08_L1TP_008058_20210528_20210607_02_T1_B6.TIF")
B4
## class : RasterLayer
## dimensions : 7741, 7581, 58684521 (nrow, ncol, ncell)
## resolution : 30, 30 (x, y)
## extent : 408285, 635715, 203385, 435615 (xmin, xmax, ymin, ymax)
## crs : +proj=utm +zone=18 +datum=WGS84 +units=m +no_defs
## source : LC08_L1TP_008058_20210528_20210607_02_T1_B4.TIF
## names : LC08_L1TP_008058_20210528_20210607_02_T1_B4
## values : 0, 65535 (min, max)
crs(B4)
## CRS arguments:
## +proj=utm +zone=18 +datum=WGS84 +units=m +no_defs
dim(B4)
## [1] 7741 7581 1
compareRaster(B4,B2)
## [1] TRUE
s <-stack(B5,B4,B3)
#PLOTEO DE BANDAS
par(mfrow=c(2,2))
plot(B1, main="Coastal Aerosol",col=gray(0:100/100))
plot(B2, main="Blue",col=gray(0:100/100))
plot(B3, main="Green",col=gray(0:100/100))
plot(B4, main="Red",col=gray(0:100/100))
plot(B5, main="Near infrared",col=gray(0:100/100))
plot(B6, main="Short wave infrared",col=gray(0:100/100))
#PLOTEAR MI COMBINACION A COLOR VERDADER0
landsatRGB <-stack(B1,B2,B3,B4,B5,B6)
plotRGB(landsatRGB, r=4,g=3,b=2,axes= TRUE, stretch= "lin",main="color verdadero")