Anexo 1
29-Enero-2022
Este cuaderno fue usado para leer el archivo .tif de los datos de precipitación de la base de datos CHIRPS.
Gran parte del codigo fue usado del cuaderno de Rstudio del profesor Ivan Lizarazo.(Referencia al final del cuaderno.)
library(rgdal)
library(raster)
library(sf)
library(tidyverse)
library(tmap)
library(gstat)
library(sp)
(precip <- raster("E:/Descargas en el disco duro/4to Semestre/Geomatica/chirps-v2.0.2020.04.tif/chirps-v2.0.2020.04.6.tif"))
class : RasterLayer
dimensions : 2000, 7200, 14400000 (nrow, ncol, ncell)
resolution : 0.05, 0.05 (x, y)
extent : -180, 180, -50, 50 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs
source : chirps-v2.0.2020.04.6.tif
names : chirps.v2.0.2020.04.6
(colombia <- st_read("E://Descargas en el disco duro/4to Semestre/Geomatica/colombia/Censo_Nacional_Agropecuario_-_Uso_de_la_tierra.shp"))
Reading layer `Censo_Nacional_Agropecuario_-_Uso_de_la_tierra' from data source
`E:\Descargas en el disco duro\4to Semestre\Geomatica\colombia\Censo_Nacional_Agropecuario_-_Uso_de_la_tierra.shp' using driver `ESRI Shapefile'
Simple feature collection with 1122 features and 25 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -81.73567 ymin: -4.228392 xmax: -66.84722 ymax: 13.39479
Geodetic CRS: WGS 84
Simple feature collection with 1122 features and 25 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -81.73567 ymin: -4.228392 xmax: -66.84722 ymax: 13.39479
Geodetic CRS: WGS 84
First 10 features:
OBJECTID COD_DEP DPTO COD_MUN MPIO HaNatura HaAgro HanoAgro HaOtro PrPropia PrArrien PrAparce PrUsufru PrComoda
1 1 99 Vichada 99001 Puerto Carreño 300074.0 892647.3 6371.8 23477.4 150 3 0 1 0
2 2 99 Vichada 99524 La Primavera 313276.0 1530281.5 185.5 19024.1 698 7 0 3 0
3 3 99 Vichada 99624 Santa Rosalía 85270.1 300823.8 0.5 4523.1 140 6 0 0 0
4 4 99 Vichada 99773 Cumaribo 3963209.5 2420787.2 3272.9 169098.8 602 32 6 2 1
5 5 97 Vaupés 97001 Mitú 1593238.4 18965.0 167.9 16671.5 89 2 2 1 0
6 6 97 Vaupés 97161 Caruru 568014.6 63804.4 42.7 8188.9 188 1 0 0 0
7 7 97 Vaupés 97511 Pacoa 1380915.5 8904.1 0.0 12577.7 2 0 0 0 0
8 8 97 Vaupés 97666 Taraira 650992.2 3277.6 0.0 520.5 166 1 0 0 0
9 9 97 Vaupés 97777 Papunaua 545677.0 9033.6 0.0 28.8 2 0 0 0 0
10 10 97 Vaupés 97889 Yavaraté 464908.1 1798.5 0.0 346.9 0 1 0 0 0
PrOcupac PrColect PrAdjudi PrOtros PrMixta UPA UPNA Shape_Leng Shape_Area ShapeSTAre ShapeSTLen geometry
1 1 130 0 7 1 1216198.8 6371.8 6.279670 0.7756909 12317792938 616588.5 MULTIPOLYGON (((-67.77352 6...
2 1 82 4 26 0 1862581.6 185.5 10.017680 1.8531276 20415619314 924297.7 MULTIPOLYGON (((-69.03111 6...
3 0 77 16 7 1 390617.0 0.5 2.333843 0.1618016 2012812969 258220.8 MULTIPOLYGON (((-70.64082 5...
4 3 2984 274 17 7 6553095.5 3272.9 18.433883 5.3056108 65933330943 2051496.6 MULTIPOLYGON (((-68.46946 5...
5 1 2453 0 10 0 1628874.9 167.9 6.269636 1.3078188 16209453255 697796.4 MULTIPOLYGON (((-70.48344 1...
6 40 56 0 13 1 640007.9 42.7 4.463306 0.5704727 7070722296 496589.1 MULTIPOLYGON (((-71.38722 1...
7 0 117 0 1 0 1402397.3 0.0 8.817896 1.1208637 13889978007 981172.7 MULTIPOLYGON (((-71.81461 0...
8 1 8 0 1 0 654790.3 0.0 6.070677 0.5236570 6489700603 675445.0 MULTIPOLYGON (((-70.01932 -...
9 0 68 1 1 0 554739.4 0.0 5.437411 0.4312044 5345769783 604913.8 MULTIPOLYGON (((-70.10474 2...
10 0 64 0 0 0 467053.6 0.0 3.765902 0.3793203 4700980029 419033.0 MULTIPOLYGON (((-69.99653 0...
(aoi <- filter(colombia, DPTO == "Putumayo"))
Simple feature collection with 13 features and 25 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -77.2273 ymin: -0.572994 xmax: -73.83733 ymax: 1.515533
Geodetic CRS: WGS 84
First 10 features:
OBJECTID COD_DEP DPTO COD_MUN MPIO HaNatura HaAgro HanoAgro HaOtro PrPropia PrArrien PrAparce PrUsufru PrComoda PrOcupac
1 37 86 Putumayo 86001 Mocoa 33130.1 91040.0 2705.3 607.8 3164 119 21 171 11 16
2 38 86 Putumayo 86219 Colón 4024.3 3168.0 6.8 6.5 504 78 15 89 0 0
3 39 86 Putumayo 86320 Orito 71889.1 84065.7 26808.1 640.4 1229 14 7 10 6 5
4 40 86 Putumayo 86568 Puerto Asís 185320.4 89866.0 5319.6 2915.9 1397 92 8 18 10 15
5 41 86 Putumayo 86569 Puerto Caicedo 24150.9 61645.0 1187.5 279.3 1268 49 21 0 0 4
6 42 86 Putumayo 86571 Puerto Guzmán 268893.6 60976.6 638.7 2186.0 127 8 1 0 0 0
7 43 86 Putumayo 86573 Leguízamo 1032672.0 49710.4 733.1 7342.5 581 16 2 7 2 30
8 44 86 Putumayo 86749 Sibundoy 7498.8 1050.8 88.9 18.0 800 304 16 419 10 12
9 45 86 Putumayo 86755 San Francisco 14271.9 26240.5 209.9 132.7 1029 105 8 17 0 0
10 46 86 Putumayo 86757 San Miguel 6039.9 25089.1 5814.8 98.0 1288 22 14 10 2 7
PrColect PrAdjudi PrOtros PrMixta UPA UPNA Shape_Leng Shape_Area ShapeSTAre ShapeSTLen geometry
1 171 3 73 55 124777.9 2705.3 3.1311956 0.11057967 1353057345 310126.69 MULTIPOLYGON (((-76.89592 1...
2 11 0 15 40 7198.7 6.8 0.4746391 0.00584655 92913644 60440.67 MULTIPOLYGON (((-76.91605 1...
3 102 0 14 0 156595.2 26808.1 2.1208913 0.14905456 1870489231 233796.72 MULTIPOLYGON (((-76.94468 0...
4 683 5 150 0 278102.3 5319.6 3.6619122 0.22901318 2759264364 412188.61 MULTIPOLYGON (((-76.36888 0...
5 123 0 16 92 86075.2 1187.5 1.5947904 0.06877949 739695850 159586.45 MULTIPOLYGON (((-76.70766 0...
6 497 0 4 0 332056.2 638.7 4.7472573 0.37107342 4622100551 502295.58 MULTIPOLYGON (((-75.9778 1....
7 718 102 3 0 1089725.0 733.1 7.6049450 0.88430728 10785270085 828227.00 MULTIPOLYGON (((-75.26459 0...
8 21 1 44 27 8567.5 88.9 0.5723493 0.00840563 111122900 51867.67 MULTIPOLYGON (((-76.88014 1...
9 21 120 57 0 40645.1 209.9 1.4231139 0.04538705 600472943 148546.87 MULTIPOLYGON (((-76.90114 1...
10 158 1 142 114 31227.0 5814.8 1.3398549 0.03133352 385571872 144352.39 MULTIPOLYGON (((-76.99674 0...
precip.crop <- raster::crop(precip, extent(aoi))
precip.mask <- mask(x = precip.crop, mask = aoi)
precip.mask
class : RasterLayer
dimensions : 41, 68, 2788 (nrow, ncol, ncell)
resolution : 0.05, 0.05 (x, y)
extent : -77.25, -73.85, -0.5500008, 1.499999 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs
source : memory
names : chirps.v2.0.2020.04.6
values : 26.44113, 102.9035 (min, max)
library(leaflet)
library(RColorBrewer)
pal <- colorNumeric(c("red", "orange", "yellow", "blue", "darkblue"), values(precip.mask),
na.color = "transparent")
leaflet() %>% addTiles() %>%
addRasterImage(precip.mask, colors = pal, opacity = 0.6) %>%
addLegend(pal = pal, values = values(precip.mask),
title = "Precipitación CHIRPS del departamento de Putumayo del 26 al 30 de agosto en 2020 [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
#####Lizarazo, I. 2020. Interpolation of CHIRPS precipitation data. https://rpubs.com/ials2un/chirps_caribe