Se cargan todas las librerias:
library(AOI)
library(climateR)
library(sf)
library(raster)
library(rasterVis)
library(dplyr)
library(leaflet)
library(RColorBrewer)
library(renv)
Se lee el archivo shapefile de Putumayo:
(putu <- st_read("E:/Descargas en el disco duro/4to Semestre/Geomatica/Putumayo/ADMINISTRATIVO/MGN_MPIO_POLITICO.shp"))
Reading layer `MGN_MPIO_POLITICO' from data source `E:\Descargas en el disco duro\4to Semestre\Geomatica\Putumayo\ADMINISTRATIVO\MGN_MPIO_POLITICO.shp' using driver `ESRI Shapefile'
Simple feature collection with 13 features and 9 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -77.18681 ymin: -0.5622776 xmax: -73.84132 ymax: 1.467315
Geodetic CRS: WGS 84
Simple feature collection with 13 features and 9 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: -77.18681 ymin: -0.5622776 xmax: -73.84132 ymax: 1.467315
Geodetic CRS: WGS 84
First 10 features:
DPTO_CCDGO MPIO_CCDGO MPIO_CNMBR MPIO_CRSLC MPIO_NAREA MPIO_NANO DPTO_CNMBR Shape_Leng Shape_Area geometry
1 86 86001 MOCOA 1958 1304.63835 2017 PUTUMAYO 2.4752281 0.105792947 POLYGON ((-76.6705 1.467315...
2 86 86219 COLÓN Decreto 2830 de Diciembre 2 de 1989 64.27462 2017 PUTUMAYO 0.4548864 0.005209533 POLYGON ((-76.96835 1.28631...
3 86 86320 ORITO Decreto 2891 de Diciembre 28 de 1978 1939.39517 2017 PUTUMAYO 2.1520883 0.157171417 POLYGON ((-77.07275 0.94231...
4 86 86749 SIBUNDOY Decreto 1871 de Julio 1 de 1982 97.73462 2017 PUTUMAYO 0.5113819 0.007922269 POLYGON ((-76.9043 1.299191...
5 86 86755 SAN FRANCISCO Decreto 2830 de Diciembre 2 de 1989 407.35674 2017 PUTUMAYO 1.1754950 0.033022563 POLYGON ((-76.87345 1.28986...
6 86 86757 SAN MIGUEL (La Dorada) Ordenanza 45 de Abril 29 de 1994 379.74249 2017 PUTUMAYO 1.3275843 0.030777834 POLYGON ((-76.99677 0.37418...
7 86 86760 SANTIAGO Decreto 2830 de Diciembre 2 de 1989 341.92382 2017 PUTUMAYO 0.9881418 0.027710081 POLYGON ((-77.0344 1.199208...
8 86 86865 VALLE DEL GUAMUEZ Decreto DAINCO 3293 de Noviembre 12 de 1985 815.15905 2017 PUTUMAYO 1.7150665 0.066065988 POLYGON ((-77.00282 0.50363...
9 86 86885 VILLAGARZÓN Decreto 574 de Marzo 14 de 1977 1396.96644 2017 PUTUMAYO 1.9280172 0.113257175 POLYGON ((-76.63426 1.06411...
10 86 86569 PUERTO CAICEDO Ordenanza 12 de Noviembre 24 de 1992 926.46719 2017 PUTUMAYO 1.7197177 0.075139258 POLYGON ((-76.41069 0.86694...
Buscamos los datos de precipitación para el año 2019 en el mes de enero…
tc_prcp = getTerraClim(putu, param = "prcp", startDate = "2019-01-01")
Spherical geometry (s2) switched off
Spherical geometry (s2) switched on
tc_tmp <- tc_prcp[[1]]
tc_tmp
class : RasterStack
dimensions : 50, 81, 4050, 1 (nrow, ncol, ncell, nlayers)
resolution : 0.04166667, 0.04166667 (x, y)
extent : -77.20833, -73.83333, -0.5833333, 1.5 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs
names : X2019.01
min values : 82.3
max values : 853.6
Se miran los resultados con la función Leaflet:
pal <- colorNumeric(c("red", "orange", "#fcc000","yellow", "cyan", "blue", "#3240cd"), values(tc_tmp$X2019.01),
na.color = "transparent")
leaflet() %>% addTiles() %>%
addRasterImage(tc_tmp$X2019.01 , colors = pal, opacity = 0.5) %>%
addLegend(pal = pal, values = values(tc_tmp$X2019.01),
title = "Lluvias en Putumayo Enero 2019 [MM]")
Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded ellps WGS 84 in Proj4 definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs
Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded datum World Geodetic System 1984 in Proj4 definition
Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded ellps WGS 84 in Proj4 definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs
Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded datum World Geodetic System 1984 in Proj4 definition
Warning in colors(.) :
Some values were outside the color scale and will be treated as NA
Con esta tabla se miran las variables disponibles para cada dato climatico:
head(param_meta$terraclim)
Buscamos los datos de deficit de agua para el periodo de 1981 a 2010 en el mes de enero:
wat_def = getTerraClimNormals(putu, param = "water_deficit", period = "19812010", month=1)
Spherical geometry (s2) switched off
Spherical geometry (s2) switched on
tc_tmp <- wat_def[[1]]
Se usa la herramienta leaflet para visualizar los datos:
pal <- colorNumeric(c("green", "#9acd32","yellow", "orange",
"#fc7300"), values(tc_tmp$X01),
na.color = "transparent")
leaflet() %>% addTiles() %>%
addRasterImage(tc_tmp$X01, colors = pal, opacity = 0.5) %>%
addLegend(pal = pal, values = values(tc_tmp$X01),
title = "Deficit de Agua Putumayo Enero")
Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded ellps WGS 84 in Proj4 definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs
Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded datum World Geodetic System 1984 in Proj4 definition
Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded ellps WGS 84 in Proj4 definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs
Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded datum World Geodetic System 1984 in Proj4 definition
Por ultimo se buscan los datos de precipitación para el mes de diciembre en el año 2019 para una comparativa:
tc_prcp2 = getTerraClim(putu, param = "prcp", startDate = "2019-12-01")
Spherical geometry (s2) switched off
Spherical geometry (s2) switched on
tc_tmp <- tc_prcp2[[1]]
Se utiliza la herramienta leaflet para visualizar los datos:
pal <- colorNumeric(c("red", "orange", "#fcc000","yellow", "cyan", "blue", "#3240cd"), values(tc_tmp$X2019.12),
na.color = "transparent")
leaflet() %>% addTiles() %>%
addRasterImage(tc_tmp$X2019.12 , colors = pal, opacity = 0.5) %>%
addLegend(pal = pal, values = values(tc_tmp$X2019.12),
title = "Lluvias en Putumayo Diciembre 2019 [mm]")
Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded ellps WGS 84 in Proj4 definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs
Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded datum World Geodetic System 1984 in Proj4 definition
Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded ellps WGS 84 in Proj4 definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs
Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded datum World Geodetic System 1984 in Proj4 definition
Todos los codigos usados en este cuarderno de R fueron tomados del cuaderno del profesor (Lizarazo, 2021).