validación de pronósticos nacionales

Cargamos las librerias

1. Definición de rutas de trabajo

## OGR data source with driver: ESRI Shapefile 
## Source: "D:\CURSOS\SIG\ARCNEW\TEMPORAL\TEMP_COLOMBIA\COLOMBIA\departamentos colombia", layer: "WGS_1984_DEPTO"
## with 33 features
## It has 6 fields
##      LON   LAT ELEV COD.SSHM COD.antiguo
## 1 -81.72 12.58    1 17015010     1701501
## 2 -81.35 13.37    1 17025020     1702502
## 3 -74.23 11.13    4 15015050     1501505
## 4 -75.52 10.19    2 14015020     1401502
## 5 -74.95 10.86   14 29045020     2904502
## 6 -72.92 11.53    4 15065010     1506501
##                                                              ESTACION
## 1                                           APTO GUSTAVO ROJA PINILLA
## 2                                                     APTO EL EMBRUJO
## 3 APTO SIMON BOLIVAR (14 Km en linea recta al occidente de la ciudad)
## 4                                                   APTO RAFAEL NUNEZ
## 5                                                    APTO E CORTISSOZ
## 6                                                    APTO ALM PADILLA
##            MUNICIPIO                           DPTO   X1  X2   X3  X4   X5
## 1         San Andrés SAN ANDRES PROVIDENCIA Y STA C 27.7 1.5  0.9 1.5  2.2
## 2        Providencia SAN ANDRES PROVIDENCIA Y STA C  3.0 0.2 12.8 1.1  0.4
## 3        Santa Marta                      MAGDALENA  0.0 0.0  0.5 0.0  0.0
## 4          Cartagena                        BOLIVAR  0.0 0.2  0.0 0.0  7.3
## 5 B/quilla (Soledad)                      ATLANTICO  0.0 0.0 46.4 0.0 15.0
## 6           Riohacha                     LA GUAJIRA  0.0 0.6  0.0 0.0  6.4
##    X6  X7  X8  X9 X10 X11 X12 X13  X14  X15 X16 X17 X18 X19  X20 X21  X22
## 1 9.2 3.1 0.5 0.2   0 0.0 0.7 6.8  5.3 13.0   0 5.3 0.9 0.2 14.4 0.6  6.2
## 2 3.7 3.4 0.0 0.0   0 1.8 0.0 2.6  0.4  1.3   0 0.8 0.0 2.9  0.1 0.0  1.0
## 3 0.0 0.0 0.0 0.0   0 0.0 0.0 0.0 18.0  0.8   0 0.0 0.0 1.4  0.0 0.0 24.4
## 4 0.0 0.0 0.0 0.0   0 0.0 0.0 0.0  6.8  1.9   0 0.0 0.0 0.0  0.0 0.0  0.1
## 5 0.0 0.0 0.0 0.0   0 0.0 0.0 0.0 28.0  0.4   0 0.0 0.0 0.0  0.0 0.0  0.0
## 6 0.0 0.0 0.0 0.0   0 0.0 0.0 0.0  0.0  8.0   0 0.0 0.0 0.0  0.0 0.0  0.0
##    X23 X24 X25 X26  X27  X28 X29 X30 X31
## 1  1.8 2.0 2.6 0.7 10.7 11.9 6.7 7.1 0.4
## 2  0.5 5.2 1.5 0.2  0.1  8.3 0.0 2.9 5.0
## 3  1.1 0.0 0.0 1.0  0.5  0.0 0.0 0.0 0.0
## 4  3.4 0.0 0.0 0.0 14.6  0.0 0.0 0.0 0.0
## 5 46.7 0.0 0.0 0.0  0.0  0.0 0.0 0.0 0.0
## 6  0.0 0.0 0.0 0.0  0.0  0.0 0.0 0.0 1.3

2. Selección de Raster

3. Mascaras con el contorno colombiano

mask_satelital <- mask(rast_satelital, DEP_COLOMBIA)
mask_smartmet <- mask(rast_smartmet, DEP_COLOMBIA)

4. Definición de paletas de colores e intervalos de colores

PALETA_OSPA <- c("#FFFFFF","#00FFFF","#00CDCD","#009ACD","#00008B","#00FF00","#00CD00","#008B00","#FFFF00","#EE9A00","#FFA500","#FF0000","#EE0000","#8B0000", "#8B008B")
BREACCS <- c(0,0.1,1,2,4,5,6,8,10,15,20,30,40,60,80,100, Inf)

val_paleta <- c("#8B1A1A","#CD2626","#EE2C2C","#FF3030","#FF4500","#EE9A00","#FFA500","#FFC125","#FFD700","#FFFAF0","#F0F8FF","#98F5FF","#8EE5EE","#7AC5CD","#00BFFF","#00B2EE","#009ACD","#00688B","#000080")

val_breack<- c(-Inf,-40,-35,-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30,35,40,Inf)

5. Definir proyección de rasters e incluir la diferencia entre ellos

nuevo_mask_smartmet <- resample(mask_smartmet, mask_satelital)
Diferencia <- mask_satelital- nuevo_mask_smartmet

6. comando para mapa interactivo

tmap_mode("view")
## tmap mode set to interactive viewing

7. Plot de mapas

## Credits not supported in view mode.
## Raster object has 3121200 (1530 by 2040) cells, which is larger than 1e+06, the maximum size determined by the option max.raster. Therefore, the raster will be shown at a decreased resolution of 1e+06 cells. Set tmap_options(max.raster = c(plot = 3121200, view = 3121200)) to show the whole raster.
## Linking to GEOS 3.6.1, GDAL 2.2.3, proj.4 4.9.3
## Raster object has 3121200 (1530 by 2040) cells, which is larger than 1e+06, the maximum size determined by the option max.raster. Therefore, the raster will be shown at a decreased resolution of 1e+06 cells. Set tmap_options(max.raster = c(plot = 3121200, view = 3121200)) to show the whole raster.
## Raster object has 3121200 (1530 by 2040) cells, which is larger than 1e+06, the maximum size determined by the option max.raster. Therefore, the raster will be shown at a decreased resolution of 1e+06 cells. Set tmap_options(max.raster = c(plot = 3121200, view = 3121200)) to show the whole raster.
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.
## Variable "layer" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.