Paquetes de R
x <- c("rgdal","magrittr","dplyr","ggplot2","sf","tidyverse")
lapply(x, library, character.only = TRUE) # carga los paquetes requeridos
## [[1]]
## [1] "rgdal" "sp" "stats" "graphics" "grDevices" "utils"
## [7] "datasets" "methods" "base"
##
## [[2]]
## [1] "magrittr" "rgdal" "sp" "stats" "graphics" "grDevices"
## [7] "utils" "datasets" "methods" "base"
##
## [[3]]
## [1] "dplyr" "magrittr" "rgdal" "sp" "stats" "graphics"
## [7] "grDevices" "utils" "datasets" "methods" "base"
##
## [[4]]
## [1] "ggplot2" "dplyr" "magrittr" "rgdal" "sp" "stats"
## [7] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[5]]
## [1] "sf" "ggplot2" "dplyr" "magrittr" "rgdal" "sp"
## [7] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
## [13] "base"
##
## [[6]]
## [1] "forcats" "stringr" "purrr" "readr" "tidyr" "tibble"
## [7] "tidyverse" "sf" "ggplot2" "dplyr" "magrittr" "rgdal"
## [13] "sp" "stats" "graphics" "grDevices" "utils" "datasets"
## [19] "methods" "base"
Mapas de México del marco geoestadístico mexicano del sitio de datos abiertos del INEGI
Fuente de datos. Marco geoestadístico https://www.inegi.org.mx/temas/mg/#Descargas
Geoentidades en https://file.coffee/u/P1uK0Tgpt4bMJf.csv
Municipios en https://file.coffee/u/NG5PUGradnGwyQ.csv
File Coffee: servicio web gratuito para compartir archivos fácilmente https://www.softandapps.info/2022/05/04/file-coffee-servicio-web-gratuito-para-compartir-archivos-facilmente/?utm_source=ReviveOldPost&utm_medium=social&utm_campaign=ReviveOldPost
#La ruta para el mapa de México se toma del Marcogeostadístico nacional
rutamc<-"D:/Documents/Claudia/Midropbox/Investigacion y escritos/Censo2020/"
geoentidades<-read.csv(paste0(rutamc,"marcogeoentidad.csv"),header=TRUE, sep=",",encoding="UTF-8")
municipios<-read.csv(paste0(rutamc,"municipios.csv"),header=TRUE, sep=",",encoding="latin")
municipios <-subset(municipios,municipios$NOM_ENT %in% c("Coahuila de Zaragoza"))
municipios <-subset(municipios,municipios$NOM_MUN %in% c("Torreón"))
titulmun<-municipios$NOM_MUN
nummun<-municipios$MUN
rutamc<-"D:/Documents/Claudia/Midropbox/Investigacion y escritos/Censo2020/889463807469_s"
codent<-substr(geoentidades$NUM_ENT,1,2)
codent<-sprintf("%02d%s", as.numeric(gsub("[^0-9]+", "", codent)), gsub("[0-9]+", "", codent))
geoentidades$COD_ENT<-codent
geoentidades <-subset(geoentidades,geoentidades$NOM_ENT %in% c("Coahuila de Zaragoza"))
codent<-geoentidades$COD_ENT
rutamc<-"D:/Documents/Claudia/Midropbox/Investigacion y escritos/Censo2020/889463807469_s/"
filename<-geoentidades$ARCHENT
#filemun<-paste0(geoentidades$COD_ENT,"mun")
#fileloc<-paste0(geoentidades$COD_ENT,"a")
#filemza<-paste0(geoentidades$COD_ENT,"m")
fileeje<-paste0(geoentidades$COD_ENT,"e")
url<-paste0(rutamc,filename,".zip")
temp2 <- tempfile()
unzip(url, exdir = temp2)
rut<-file.path(temp2)
rutamun<-paste0(rut,"/conjunto_de_datos")
#basemapamun <- readOGR(rutamun,filemun, use_iconv = TRUE, encoding = "latin1")
snummun<-sprintf("%03d%s", as.numeric(gsub("[^0-9]+", "", nummun)), gsub("[0-9]+", "", nummun))
#basemapamun<-subset(basemapamun,basemapamun$CVE_MUN %in% c(snummn))
#basemapaloc <- readOGR(rutamun,fileloc, use_iconv = TRUE, encoding = "latin1")
#basemapaloc<-subset(basemapaloc,basemapaloc$CVE_MUN %in% c(snummun))
#basemapeje <- readOGR(rutamun,fileeje, use_iconv = TRUE, encoding = "latin1")
#basemapeje<-subset(basemapeje,basemapeje$CVE_MUN %in% c(snummun))
#shpfile2 <- spTransform(basemapaloc,
#CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
#shpfile3 <- spTransform(basemapamun,
#CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
#proj4string(basemapeje)
#shpfile4 <- spTransform(basemapeje,
#CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
#map <- ggplot() +
# geom_line(data = shpfile4, aes(x = long, #y = lat, group = group), colour = "black", #fill = "white", size = .8)+ coord_map()
#map + theme_void()
#ggsave("muntor_map.png", width = 1300, height = 1300, units = "mm", dpi = "retina",limitsize = FALSE)
ylim=c(25.47, 25.67)
xlim=c(-103.30, -103.52)
#map <- ggplot() +
# geom_line(data = shpfile4, aes(x = long, y = lat, group = group), colour = "black", fill = "white", size = .8)+ coord_sf(xlim=xlim, ylim=ylim)
#map + theme_void()
#ggsave("torreon_map.svg", width = 1300, height = 1300, units = "mm", dpi = "retina",limitsize = FALSE)
#Guardar archivo
#writeOGR(shpfile4, ".", "muntor",
# driver = "ESRI Shapefile")