#Procedemos a instalar las paqueterías que se van a usar
library(rgdal)
library(readxl)
library(RColorBrewer)
library(leaflet)
library(dplyr)
library(htmltools)
mapa_guerrero<-readOGR("C:\\Users\\permi\\Desktop\\CIDE\\Primer semestre\\R\\Guerrero\\conjunto_de_datos",layer = "guerrero_mun")
## OGR data source with driver: ESRI Shapefile
## Source: "C:\Users\permi\Desktop\CIDE\Primer semestre\R\Guerrero\conjunto_de_datos", layer: "guerrero_mun"
## with 81 features
## It has 4 fields
guerrero <- read_excel("C:\\Users\\permi\\Desktop\\CIDE\\Primer semestre\\R\\Guerrero\\guerrero.xlsx")
guerrero$`Clave de Municipio`<-substr(guerrero$`Clave de Municipio`,3,5)
guerrero_P10<-guerrero[,c(3,5)]
tabla_P10<-merge(x=mapa_guerrero@data ,y=guerrero_P10,by.x="CVE_MUN",by.y="Clave de Municipio", sort=FALSE)
mapa_guerrero@data$Pobreza10<-tabla_P10$P_2010
my_colors_P10<-brewer.pal(5,"Reds")
my_colors_P10<-colorRampPalette(my_colors_P10)(4)
cuantil_P10<-cut(mapa_guerrero@data$Pobreza10 ,4)
my_colors_P10<-my_colors_P10[as.numeric(cuantil_P10)]
#Levels: (45.3,58.7] (58.7,71.9] (71.9,85.2] (85.2,98.5]
cortess <- c(45.3,58.7,71.9,85.2,Inf)
colores <- colorBin( palette="Reds", domain=mapa_guerrero$Pobreza10 ,na.color="transparent", bins=cortess)
textoss <- paste(
"Municipio : ",mapa_guerrero$NOMGEO ,"<br/>",
"Porcentaje de Pobreza: ", round(mapa_guerrero$Pobreza10 ,2),"<br/>" ) %>% lapply(htmltools::HTML)
leaflet(data=mapa_guerrero ) %>%
addTiles() %>%
addPolygons(label = textoss,fillColor = colores(mapa_guerrero$Pobreza10), weight = 2, opacity = 1, color = "white", dashArray = "3",
fillOpacity = 0.9) %>%
addLegend("topleft", colors = c("#FEE5D9", "#FB9779", "#E74132", "#A50F15"),
labels= c("(45.3%-58.7%)","(58.7%-71.9%)","(71.9%-85.2%)","(85.2%-98.5%)"),
title= "Distribución de la pobreza por municipio (2010). ", opacity = 0.9)
guerrero_P15<-guerrero[,c(3,6)]
tabla_P15<-merge(x=mapa_guerrero@data ,y=guerrero_P15,by.x="CVE_MUN",by.y="Clave de Municipio", sort=FALSE)
mapa_guerrero@data$Pobreza15<-tabla_P15$P_2015
my_colors_P15<-brewer.pal(5,"PuBuGn")
my_colors_P15<-colorRampPalette(my_colors_P15)(4)
cuantil_P15<-cut(mapa_guerrero@data$Pobreza15 ,4)
my_colors_P15<-my_colors_P15[as.numeric(cuantil_P15)]
# Levels: (48.1,61] (61,73.7] (73.7,86.5] (86.5,99.4]
cortess <- c(48.1,61,73.7,86.5,Inf)
colores <- colorBin( palette="Reds", domain=mapa_guerrero$Pobreza10 ,na.color="transparent", bins=cortess)
textoss <- paste(
"Municipio : ",mapa_guerrero$NOMGEO ,"<br/>",
"Porcentaje de Pobreza: ", round(mapa_guerrero$Pobreza15 ,2),"<br/>" ) %>% lapply(htmltools::HTML)
leaflet(data=mapa_guerrero ) %>%
addTiles() %>%
addPolygons(label = textoss,fillColor = colores(mapa_guerrero$Pobreza15), weight = 2, opacity = 1, color = "white", dashArray = "3",
fillOpacity = 0.9) %>%
addLegend("topleft", colors = c("#FEE5D9", "#FB9779", "#E74132", "#A50F15"),
labels= c("(48.1%-61%)","(61%-73.7%)","(73.7%-86.5%)","(86.5%-99.4%)"),
title= "Distribución de la pobreza por municipio (2015).", opacity = 0.9)
# Levels: (48.1,61] (61,73.7] (73.7,86.5] (86.5,99.4]
guerrero_PE10<-guerrero[,c(3,7)]
tabla_PE10<-merge(x=mapa_guerrero@data ,y=guerrero_PE10,by.x="CVE_MUN",by.y="Clave de Municipio", sort=FALSE)
mapa_guerrero@data$PobrezaE10<-tabla_PE10$PE_2010
my_colors_PE10<-brewer.pal(5,"PuBuGn")
my_colors_PE10<-colorRampPalette(my_colors_PE10)(4)
cuantil_PE10<-cut(mapa_guerrero@data$PobrezaE10 ,4)
my_colors_PE10<-my_colors_PE10[as.numeric(cuantil_PE10)]
#Levels: (10.2,29.7] (29.7,49.1] (49.1,68.5] (68.5,88]
cortess <- c(10.2,29.7,49.1,68.5,Inf)
colores <- colorBin( palette="Reds", domain=mapa_guerrero$PobrezaE10 ,na.color="transparent", bins=cortess)
textoss <- paste(
"Municipio : ",mapa_guerrero$NOMGEO ,"<br/>",
"Porcentaje de Pobreza: ", round(mapa_guerrero$PobrezaE10 ,2),"<br/>" ) %>% lapply(htmltools::HTML)
leaflet(data=mapa_guerrero ) %>%
addTiles() %>%
addPolygons(label = textoss,fillColor = colores(mapa_guerrero$PobrezaE10), weight = 2, opacity = 1, color = "white", dashArray = "3",
fillOpacity = 0.9) %>%
addLegend("topleft", colors = c("#FEE5D9", "#FB9779", "#E74132", "#A50F15"),
labels= c("(10.2%-29.7%)","(29.7%-49.1%)","(49.1%-68.5%)","(68.5%-88%)"),
title= "Distribución de pobreza extrema por municipio (2010).", opacity = 0.9)
guerrero_PE15<-guerrero[,c(3,8)]
tabla_PE15<-merge(x=mapa_guerrero@data ,y=guerrero_PE15,by.x="CVE_MUN",by.y="Clave de Municipio", sort=FALSE)
mapa_guerrero@data$PobrezaE15<-tabla_PE15$PE_2015
my_colors_PE15<-brewer.pal(5,"PuBuGn")
my_colors_PE15<-colorRampPalette(my_colors_PE15)(4)
cuantil_PE10<-cut(mapa_guerrero@data$PobrezaE15,4)
my_colors_PE15<-my_colors_PE15[as.numeric(cuantil_PE10)]
#Levels: (8,28] (28,47.9] (47.9,67.8] (67.8,87.8]
cortess <- c(8,28,47.9,67.8,Inf)
colores <- colorBin( palette="Reds", domain=mapa_guerrero$PobrezaE15 ,na.color="transparent", bins=cortess)
textoss <- paste(
"Municipio : ",mapa_guerrero$NOMGEO ,"<br/>",
"Porcentaje de Pobreza: ", round(mapa_guerrero$PobrezaE15 ,2),"<br/>" ) %>% lapply(htmltools::HTML)
leaflet(data=mapa_guerrero ) %>%
addTiles() %>%
addPolygons(label = textoss,fillColor = colores(mapa_guerrero$PobrezaE15), weight = 2, opacity = 1, color = "white", dashArray = "3",
fillOpacity = 0.9) %>%
addLegend("topleft", colors = c("#FEE5D9", "#FB9779", "#E74132", "#A50F15"),
labels= c("(8%-28%)","(28%-47.9%)","(47.9%-67.8%)","(67.8%-87.8%)"),
title= "Distribución de pobreza extrema por municipio (2015).", opacity = 0.9)
No, no se distribuye de manera aleatoria, comparando los mapas dónde se muestra la distribución de pobreza extrema en el estado de Guerrero (en porcentaje %) para los años 2010 y 2015 se puede observar que hay ciertos municipio donde prevalece los mayores porcentajes de pobreza extrema. Los municipios del sureste del estado de Guerrero tales como Cochoapa el Grande, Metlatanoc, Alcouzaca de Guerrero, Atlamajalcingo del Monte,Metlatónoc y Acatepec. De la misma manera, prevalece la pobreza extrema pero en un menor porcentaje para los municipios de los alrededores.