3.5 Poverty Map
This code block loads various packages (sf, tmap) and performs several operations. Initially, it conducts a left_join between the benchmark-adjusted estimates (estimacionesBench) and the model estimates (data_dir, data_syn), utilizing the dam2 variable as the key for the join. Subsequently, it reads a Shapefile containing geospatial information for the country. Then, it creates a thematic map (tmap) using the tm_shape() function and adds layers using the tm_polygons() function. The map represents a variable theta_pred_RBench utilizing a color palette named “YlOrRd” and sets the intervals’ breaks for the variable with the variable brks_lp. Finally, the tm_layout() function sets some design parameters for the map, such as the aspect ratio (asp).
library(sf)
library(tmap)
estimacionesBench %<>% left_join(
bind_rows(
data_dir %>% select(dam2, pobreza, pred_arcoseno_EE , Cv_pred),
data_syn %>% select(dam2,pobreza, pred_arcoseno_EE , Cv_pred)))
## Leer Shapefile del país
ShapeSAE <- read_sf("Shapefile/JAM2_cons.shp")
mapa <- tm_shape(ShapeSAE %>%
left_join(estimacionesBench, by = "dam2"))
tmap_options(check.and.fix = TRUE)
Mapa_lp <-
mapa + tm_polygons(
c("pobreza","theta_pred_RBench"),
title = "Poverty map",
palette = "YlOrRd",
colorNA = "white"
) + tm_layout(asp = 1.5)
tmap_save(Mapa_lp,
filename = "Recursos/04_FH_Arcosin/09_map.png",
width = 2500,
height = 2000,
asp = 0)
Mapa_lp