Creación de Base de Datos
Nombre_Estado<-matrix(c("Aguascalientes","Baja California", "Baja California Sur", "Campeche",
Warning message:
R graphics engine version 15 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.
"Chiapas","Chihuahua","Coahuila de Zaragoza", "Colima", "Distrito Federal",
"Durango", "Guanajuato", "Guerrero", "Hidalgo", "Jalisco",
"México","Michoacán","Morelos", "Nayarit", "Nuevo León",
"Oaxaca", "Puebla", "Querétaro de Arteaga", "Quintana Roo",
"San Luis PotosÃ", "Sinaloa", "Sonora", "Tabasco", "Tamaulipas",
"Tlaxcala","Veracruz de Ignacio de la Llave", "Yucatán","Zacatecas"),ncol=1)
Clave_Estado<-matrix(1:nrow(Nombre_Estado),ncol=1)
ISG_Agro<-matrix(rep(0.5797309,nrow(Nombre_Estado)),ncol=1)
ISG_NoAgro<-matrix(rep(0.3538725,nrow(Nombre_Estado)),ncol=1)
Pob_Agro<-matrix(c(0.171437297,0.073082511,0.135354444,0.235687869,0.455839936,
0.151538566,0.095519534,0.106611503,0.003957267,0.295223863,
0.290231037,0.398007112,0.462174548,0.130611846,0.114190167,
0.305250899,0.155893757,0.309403549,0.052784681,0.517866352,
0.268259095,0.272750103,0.102981990,0.347363291,0.264353932,
0.135255385,0.414790031,0.116908945,0.208936359,0.370052252,
0.14868932,0.397911937),ncol=1)
Pob_NoAgro<-matrix(rep(1,nrow(Pob_Agro)),ncol=1)
Pob_NoAgro<-Pob_NoAgro-Pob_Agro
ISG_Agro_Est<-ISG_Agro*Pob_Agro
ISG_NoAgro_Est<-ISG_NoAgro*Pob_NoAgro
ISG_Tot<-ISG_Agro_Est+ISG_NoAgro_Est
Estado<-data.frame(Nombre_Estado,Clave_Estado,ISG_Agro,ISG_NoAgro,Pob_Agro,
Pob_NoAgro,ISG_Agro_Est,ISG_NoAgro_Est,ISG_Tot)
View(Estado)
Mapa:
library(ggplot2)
library(tidyverse)
library(dplyr)
library(raster)
library(sf)
Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
Mex_ISG<-data_frame(Estado$Clave_Estado,Estado$ISG_Tot)
colnames(Mex_ISG) <- c("Clave_Estado", "ISG_Tot")
#Mex_Mapa<-st_read("México_Estados.shx")
dfMex<-getData("GADM",country="MEX",level=1)%>%
st_as_sf()
Warning in getData("GADM", country = "MEX", level = 1) :
getData will be removed in a future version of raster
. Please use the geodata package instead
dfMex$Clave_Estado<-matrix(1:32,ncol=1)
Estados<- merge(dfMex,Mex_ISG, by="Clave_Estado")
head(Estados,15)
Simple feature collection with 15 features and 12 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -118.3689 ymin: 14.53292 xmax: -89.01215 ymax: 32.71804
Geodetic CRS: +proj=longlat +datum=WGS84 +no_defs
First 10 features:
Clave_Estado GID_0 NAME_0 GID_1 NAME_1 VARNAME_1 NL_NAME_1 TYPE_1
1 1 MEX Mexico MEX.1_1 Aguascalientes <NA> <NA> Estado
2 2 MEX Mexico MEX.3_1 Baja California <NA> <NA> Estado
3 3 MEX Mexico MEX.2_1 Baja California Sur <NA> <NA> Estado
4 4 MEX Mexico MEX.4_1 Campeche <NA> <NA> Estado
5 5 MEX Mexico MEX.5_1 Chiapas <NA> <NA> Estado
6 6 MEX Mexico MEX.6_1 Chihuahua <NA> <NA> Estado
7 7 MEX Mexico MEX.7_1 Coahuila <NA> <NA> Estado
8 8 MEX Mexico MEX.8_1 Colima <NA> <NA> Estado
9 9 MEX Mexico MEX.9_1 Distrito Federal <NA> <NA> Distrito Federal
10 10 MEX Mexico MEX.10_1 Durango <NA> <NA> Estado
ENGTYPE_1 CC_1 HASC_1 ISG_Tot geometry
1 State <NA> MX.AG 0.3925931 MULTIPOLYGON (((-102.448 21...
2 State <NA> MX.BN 0.3703788 MULTIPOLYGON (((-115.3619 2...
3 State <NA> MX.BS 0.3844434 MULTIPOLYGON (((-114.7115 1...
4 State <NA> MX.CM 0.4071046 MULTIPOLYGON (((-91.79708 1...
5 State <NA> MX.CP 0.4568278 MULTIPOLYGON (((-92.86153 1...
6 State <NA> MX.CH 0.3880988 MULTIPOLYGON (((-104.9992 2...
7 State <NA> MX.CA 0.3754464 MULTIPOLYGON (((-100.7917 2...
8 State <NA> MX.CL 0.3779516 MULTIPOLYGON (((-104.4854 1...
9 Federal District <NA> MX.DF 0.3547663 MULTIPOLYGON (((-98.86538 1...
10 State <NA> MX.DU 0.4205513 MULTIPOLYGON (((-104.9649 2...
ggplot(Estados) +
geom_sf(aes(fill = ISG_Tot))+
labs(title = "Porcentaje de población en situación de pobreza por ingreso",subtitle = "A nivel estatal",
caption = "Fuente: ENIGH (2022)",
x="Longitud",
y="Latitud")+
scale_fill_continuous(guide_legend(title = "ISG"))