Distintos niveles de zonas de datos censales, manzanas, AGEBS y las que la gente si conoce cómo son las colonias Acotación de zonas geográficas con datos de población.
x <- c("ggmap", "rgdal", "rgeos", "maptools", "dplyr", "tidyr", "tmap","dismo","raster")
# instalación de paquetes, con lapply se aplica una función sobre una lista de vectores.
lapply(x, library, character.only = TRUE) # carga los paquetes requeridos
## Map
tormap <- gmap("Torreon Coahuila")
ruta<-"D:/Documents/Claudia/Midropbox/CentroHistórico/CARTOGRAFÍA/05"
ruta2<-"D:/Documents/Claudia/Midropbox/CentroHistórico/CENSO2010/"
ruta3<-"D:/Documents/Claudia/Midropbox/CentroHistórico/CENSO2010/ESPACIOS INEGI/"
ruta4<-"D:/Documents/Claudia/Midropbox/CentroHistórico/CARTOGRAFÍA/05/colonias torreon/"
torreon.map <- readOGR(paste0(ruta,"."),"torreoncenso") #censo por mazanas
## OGR data source with driver: ESRI Shapefile
## Source: "D:\Documents\Claudia\Midropbox\CentroHistórico\CARTOGRAFÍA\05", layer: "torreoncenso"
## with 9635 features
## It has 203 fields
agebscensoparcialcoah.map<-readOGR(paste0(ruta,"."),"agebscensoparcialcoah") #censo por agebs coahuila solo algunas variables
## OGR data source with driver: ESRI Shapefile
## Source: "D:\Documents\Claudia\Midropbox\CentroHistórico\CARTOGRAFÍA\05", layer: "agebscensoparcialcoah"
## with 1838 features
## It has 11 fields
torreonageb.map<-agebscensoparcialcoah.map[ substr(agebscensoparcialcoah.map$cvegeo,3,5) =="035",]
#"cvegeoageb","ageb","pobtot","pobmas","pobfem","p_60ymas","p_60ymas_m","p_60ymas_f","pob65_mas"
torreonageb.map$Pob <- torreonageb.map$pobtot
m<-qtm(torreonageb.map, "Pob", fill.title = "#Población Total\n(1)", scale = 0.5, fill.palette="Spectral", contrast=.1)+
tm_layout(legend.position = c(0.02,0.02),legend.text.size = 1.5,legend.outside=TRUE)
print(m)
torreonageb.map$Pob <- torreonageb.map$p_60ymas
m<-qtm(torreonageb.map, "Pob", fill.title = "#Pob. 60 y mas\n(1)", scale = 0.5, fill.palette="Spectral", contrast=.1)+
tm_layout(legend.position = c(0.02,0.02),legend.text.size = 1.5,legend.outside=TRUE)
print(m)
torreon.map$Pob <- torreon.map$pobtot
m<-qtm(torreon.map, "Pob", fill.title = "#Población Total\n(1)", scale = 0.5, fill.palette="Spectral", contrast=.1)+
tm_layout(legend.position = c(0.02,0.02),legend.text.size = 1.5,legend.outside=TRUE)
print(m)
torreon.map$Pob <- torreon.map$p_60ymas
m<-qtm(torreon.map, "Pob", fill.title = "#Pob. 60 y mas\n(1)", scale = 0.5, fill.palette="Spectral", contrast=.1)+
tm_layout(legend.position = c(0.02,0.02),legend.text.size = 1.5,legend.outside=TRUE)
print(m)
Polígonos seleccionados del México INEGI Servicios Espacio y Datos http://www.beta.inegi.org.mx/app/mapa/espacioydatos/ Las colonias se obtuvieron en: http://www.trcimplan.gob.mx/ibc-colonias-torreon/ibc-colonias-torreon-20170615.zip Seleccionar el área polígono de análisis y solicitar el archivo
agebscentro<-read.csv(paste0(ruta3,"INEGI_AGEB_.csv"))
agebscentro<-list(agebscentro$CVEGEO)
#head(agebscentro)
torreonagebscentro<-torreonageb.map[torreonageb.map$cvegeo %in% agebscentro[[1]],]
#grabado del archivo del censo de las manzanas seleccionadas
#head(torreonagebscentro)
#writeOGR(torreonagebscentro, paste0(ruta,"."), layer="torreonagebscentro", driver="ESRI Shapefile")
torreonagebscentro <- readOGR(dsn = paste0(ruta,"."), layer ="torreonagebscentro") #censo por agebs zona celeccionada
## OGR data source with driver: ESRI Shapefile
## Source: "D:\Documents\Claudia\Midropbox\CentroHistórico\CARTOGRAFÍA\05", layer: "torreonagebscentro"
## with 28 features
## It has 12 fields
torreonagebscentro <- spTransform(torreonagebscentro, CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
reprojected.torreonagebscentro <- spTransform(torreonagebscentro, tormap@crs)
plot(tormap)
plot(reprojected.torreonagebscentro,add=T, border="red")
manzanascentro<-read.csv(paste0(ruta3,"INEGI_Manzanas_.csv"))
#manzanascentro<-list(paste0("0", manzanascentro$CVEGEO))
manzanascentro<-list(manzanascentro$CVEGEO)
torreonmanzanascentro<-torreon.map[torreon.map$cvegeo %in% manzanascentro[[1]],]
#grabado del archivo del censo de las manzanas seleccionadas
#writeOGR(torreonmanzanascentro, paste0(ruta,"."), layer="torreonmanzanascentro", driver="ESRI Shapefile")
torreonmanzanascentro <- readOGR(paste0(ruta,"."),"torreonmanzanascentro")
## OGR data source with driver: ESRI Shapefile
## Source: "D:\Documents\Claudia\Midropbox\CentroHistórico\CARTOGRAFÍA\05", layer: "torreonmanzanascentro"
## with 605 features
## It has 204 fields
torreonmanzanascentro <- spTransform(torreonmanzanascentro, CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
reprojected.torreonmanzanascentro <- spTransform(torreonmanzanascentro, tormap@crs)
plot(tormap)
plot(reprojected.torreonmanzanascentro,add=T, border="red")
# This is the modified version of the code, to create the map displayed
Torreonagebss<-torreonagebscentro
Torreonagebss$Pob <- Torreonagebss$pobtot / 1
m<-qtm(Torreonagebss, "Pob", fill.title = "#Personas\n(1)", scale = 0.5, fill.palette="-Blues", contrast=.1)+
tm_layout(legend.position = c(0.02,0.02),legend.text.size = 1.5,legend.outside=TRUE)
m
Torreonagebss$Pob <- as.numeric(Torreonagebss$pob65_mas) / 1
m<-qtm(Torreonagebss, "Pob", fill.title = "#Personas 65 o más", scale = 0.5, fill.palette="-Greens", contrast=.1)+
tm_layout(legend.position = c("left", "top"),legend.text.size = 1.5,legend.outside=TRUE)
m
Torreonagebss$Pob <- as.numeric(Torreonagebss$p_60ymas) / 1
m<-qtm(Torreonagebss, "Pob", fill.title = "% 60 y más", scale = 0.5, fill.palette="Spectral", contrast=.1)+
tm_layout(legend.position = c("left", "top"),legend.text.size = 1.5,legend.outside=TRUE)
m
Torreonagebss$Pob <- (as.numeric(Torreonagebss$pob65_mas) / Torreonagebss$pobtot)
m<-qtm(Torreonagebss, "Pob", fill.title = "% 65 o más/Total", scale = 0.5, fill.palette="Spectral", contrast=.1)+
tm_layout(legend.position = c("left", "top"),legend.text.size = 1.5,legend.outside=TRUE)
m
Torreonagebss<-torreonmanzanascentro
Torreonagebss$Pob <- Torreonagebss$pobtot / 1
m<-qtm(Torreonagebss, "Pob", fill.title = "#Personas\n(1)", scale = 0.5, fill.palette="-Blues", contrast=.1)+
tm_layout(legend.position = c(0.02,0.02),legend.text.size = 1.5,legend.outside=TRUE)
m
Torreonagebss$Pob <- as.numeric(Torreonagebss$pob65_mas) / 1
m<-qtm(Torreonagebss, "Pob", fill.title = "#Personas 65 o más", scale = 0.5, fill.palette="-Greens", contrast=.1)+
tm_layout(legend.position = c("left", "top"),legend.text.size = 1.5,legend.outside=TRUE)
m
Torreonagebss$Pob <- as.numeric(Torreonagebss$p_60ymas) / 1
m<-qtm(Torreonagebss, "Pob", fill.title = "% 60 y más", scale = 0.5, fill.palette="Spectral", contrast=.1)+
tm_layout(legend.position = c("left", "top"),legend.text.size = 1.5,legend.outside=TRUE)
m
Torreonagebss$Pob <- (as.numeric(Torreonagebss$pob65_mas) / Torreonagebss$pobtot)
m<-qtm(Torreonagebss, "Pob", fill.title = "% 65 o más/Total", scale = 0.5, fill.palette="Spectral", contrast=.1)+
tm_layout(legend.position = c("left", "top"),legend.text.size = 1.5,legend.outside=TRUE)
m
torreoncolonias<- readOGR(dsn = paste0(ruta4,"."), layer ="ibccoloniastorreon20170615") #implan
## OGR data source with driver: ESRI Shapefile
## Source: "D:\Documents\Claudia\Midropbox\CentroHistórico\CARTOGRAFÍA\05\colonias torreon", layer: "ibccoloniastorreon20170615"
## with 399 features
## It has 38 fields
## Integer64 fields read as strings: pobtot hogares aetot
torreoncolonias <- spTransform(torreoncolonias, CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
reprojected.torreoncolonias <- spTransform(torreoncolonias, tormap@crs)
plot(tormap)
plot(reprojected.torreoncolonias,add=T, border="red")
torreon.map <- spTransform(torreon.map, CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
reprojected.torreon.map <- spTransform(torreon.map, tormap@crs)
agebscensoparcialcoah.map <- spTransform(agebscensoparcialcoah.map, CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
reprojected.agebscensoparcialcoah.map <- spTransform(agebscensoparcialcoah.map, tormap@crs)
plot(tormap)
plot(reprojected.torreon.map,add=T, border="red")
plot(reprojected.agebscensoparcialcoah.map,add=T, border="blue")
plot(reprojected.torreoncolonias,add=T, border="green")
#torreon.map <- spTransform(torreon.map, CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
reprojected.torreon.map <- spTransform(torreon.map, tormap@crs)
#agebscensoparcialcoah.map <- spTransform(agebscensoparcialcoah.map, CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
reprojected.agebscensoparcialcoah.map <- spTransform(agebscensoparcialcoah.map, tormap@crs)
plot(tormap)
plot(reprojected.agebscensoparcialcoah.map,add=T, border="blue")
plot(reprojected.torreoncolonias,add=T, border="red")