Sistemas de Mallas Globales y Discretas (DGGS, por sus siglas en inglés Uso de la malla estadística Conjunto de datos vectoriales de la alla para la publicación estadística y geográfica Descarga: https://inegi.org.mx/infraestructura/malla/#mapas https://inegi.org.mx/app/biblioteca/ficha.html?upc=889463868842

Malla geoestadística por municipio

Incorporación de la zona municipal de Torreón en el polígono urbano Uso de consultas para la lectura filtrada del Shapefile del contexto estatal filtrado municipal

Contexto geográfico

https://inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/geografia/marcogeo/794551132173_s.zip

ruta<-"C:/Users/cguer/Documents/Claudia/Midropbox/Investigacion y escritos/karamanis/data/conjunto_de_datos/"
infile <- "05mun.shp"
nomarchi<-as.filename(paste0(ruta,infile))
nomfil<-"05mun"
a<-"SELECT * FROM \"05mun\" WHERE CVE_ENT = '05' AND CVE_MUN='035'"


datageot<- read_sf(nomarchi,options = "ENCODING=latin1",query=a)
datageot= st_transform(datageot, crs = 4326)
datageo_geom <- st_geometry(datageot)
polygon = st_cast(datageo_geom, "POLYGON") 


tor<-polygon[2]
plot(tor)

sps <- 
  tor %>%
  sf::st_coordinates() %>%
  as.data.frame() 


sps <- 
  sps[c("X","Y")]



sps <- sps %>%
  st_as_sf(coords = c("X", "Y")) %>%
  summarize(geometry = st_union(geometry)) %>%
  st_convex_hull()

st_crs(sps) <- CRS("+proj=longlat +datum=WGS84 +no_defs")
bb <- sps %>% 
  pull(geometry) %>% 
  st_as_text()

El archivo es demasiado grande por lo que se puede hacer la lectura de la malla del municipio con una consulta SQL en archivos de formato gpkg

ruta<-"C:/Users/cguer/Documents/Claudia/Midropbox/Investigacion y escritos/karamanis/portraits/torreon/"
infile <- "malla_nivel10.gpkg"
nomarchi<-as.filename(paste0(ruta,infile))
geopackage = "nomarchi"

lyrs = st_layers(infile)

nomfil<-"n10_malla_rhealpix"
a<-glue("SELECT * FROM ", nomfil, " WHERE st_intersects(geom, st_polygonfromtext(")
c<-paste0(a,"'",bb,"' ))")
recorteosmlayer4<-read_sf(nomarchi, query = c)
#plot(recorteosmlayer4$geom)

g <- ggplot() +
  geom_sf(data = recorteosmlayer4, fill = NA) +
    geom_sf(data = tor, fill=NA,color="navy",linewidth = 0.5) +

  labs(
    title = "Malla geoestadística nivel 10 de Torreón"
  ) +
  theme_minimal(
    base_family = "body_font",
    base_line_size = unit(0.1, "mm")
  ) +
  theme(
    plot.title = element_text(size = 30)
  )
g

Malla geoestadística de acuerdo a algún asentamiento nacional

Recuperación de archivo de asentamientos en el INEGI Ejemplo del municipio de Guadalajara y de las Colonias que llevan el nombre de Providencia Asentamientos humanos INEGI

Colonias https://www.inegi.org.mx/programas/dcah/

ruta<-"C:/Users/cguer/Documents/Claudia/Midropbox/Investigacion y escritos/karamanis/data/conjunto_de_datos/"
infile <- "00as.shp"
nomarchi<-as.filename(paste0(ruta,infile))
nomfil<-"00as"
a<-"SELECT * FROM \"00as\" WHERE CVE_ENT = '14' AND CVE_MUN='039'"
`%notin%` <- Negate(`%in%`)

datageot<- read_sf(nomarchi,options = "ENCODING=latin1",query=a)
#datageot<- read_sf(nomarchi,options = "ENCODING=latin1")
datageot= st_transform(datageot, crs = 4326)
#unique(datageot$TIPO)
#datageot<- datageot|> filter(NOM_ASEN %in% c("PROVIDENCIA","PROVIDENCIA CUARTA SECCIÓN","PROVIDENCIA QUINTA SECCIÓN","PROVIDENCIA SEGUNDA #SECCIÓN","PROVIDENCIA SUR","PROVIDENCIA TERCERA SECCIÓN","PRADOS PROVIDENCIA"))
datageot<- datageot|> filter(NOM_ASEN %in% c("JARDINES DEL BOSQUE NORTE","JARDINES DEL BOSQUE CENTRO"))



    

g <- ggplot() +
  #geom_sf(data = tor, fill = NA) +
  geom_sf(data = datageot, aes(fill = TIPO),alpha=.7) +
  scale_fill_manual(values = c("#f94144",
                               "#f9844a",
                               "#277da1",
                               "#90be6d",
                               "#f9c74f",
                               "#f9a64f",

                               
                               "#577590",
                               "#f0028a"
                                         ))+

  labs(
    title = "Asentamientos humanos en Guadalajara") +
  theme_minimal(
    base_family = "body_font",
    base_line_size = unit(0.1, "mm")
  ) +
  theme(
    legend.position = "bottom",
    legend.key.width = unit(3, "line"),
    legend.key.height = unit(0.5, "line"),
    plot.background = element_rect(fill = NA, color = NA),
    plot.title = element_text(size = 30,  hjust = 0.5, face = "bold"),
    plot.subtitle = element_text(size = 16,  hjust = 0.5),
    plot.caption = element_text(size = 10,  hjust = 0.5, margin = margin(20, 0, 0, 0))
    
  )


g

Recuperación de vías de caminos en OSMDATA

lim<-st_bbox(datageot)

q <- opq(bbox = c(lim$xmin, lim$ymin, lim$xmax, lim$ymax))%>% 
  add_osm_feature(key = "highway") %>% 
  osmdata_sf()
qosm_sf <- q$osm_lines 
st_crs(qosm_sf) <-4326

plot(qosm_sf$geometry)

sps <- 
  datageot %>%
  sf::st_coordinates() %>%
  as.data.frame() 


sps <- 
  sps[c("X","Y")]


sps <- sps %>%
  st_as_sf(coords = c("X", "Y")) %>%
  summarize(geometry = st_union(geometry)) %>%
  st_convex_hull()

st_crs(sps) <- CRS("+proj=longlat +datum=WGS84 +no_defs")
bb <- sps %>% 
  pull(geometry) %>% 
  st_as_text()


# lectura de malla con SQL del asentamiento 


ruta<-"C:/Users/cguer/Documents/Claudia/Midropbox/Investigacion y escritos/karamanis/portraits/torreon/"
infile <- "malla_nivel10.gpkg"
nomarchi<-as.filename(paste0(ruta,infile))
geopackage = "nomarchi"

nomfil<-"n10_malla_rhealpix"
a<-glue("SELECT * FROM ", nomfil, " WHERE st_intersects(geom, st_polygonfromtext(")
c<-paste0(a,"'",bb,"' ))")
recorteosmlayer4<-read_sf(nomarchi, query = c)
#plot(recorteosmlayer4$geom)

g <- ggplot() +
  geom_sf(data = recorteosmlayer4, fill = NA) +

  labs(
    title = "Malla geoestadística nivel 10 de Guadalajara colonias 'Jardines del Bosque' "
  ) +
  theme_minimal(
    base_family = "body_font",
    base_line_size = unit(0.1, "mm")
  ) +
  theme(
    plot.title = element_text(size = 20)
  )
g

xlim <- c(lim$xmin,lim$xmax)
ylim <- c(lim$ymin,lim$ymax)

g <- ggplot() +
  geom_sf(data = recorteosmlayer4, fill = NA) +
    geom_sf(data = datageot, fill=NA,color="navy",linewidth = 0.5) +
      geom_sf(data = qosm_sf, color="red",fill = NA, linewidth = 0.1) +


  labs(
    title = "Malla geoestadística nivel 10 Colonias 'Jardínes del Bosque' Guadalajara"
  ) +
  theme_minimal(
    base_family = "body_font",
    base_line_size = unit(0.1, "mm")
  ) +
  theme(
    plot.title = element_text(size = 20)
  )+
  coord_sf(xlim = xlim, ylim = ylim)

g

Malla geoestadística de la metrópoli lagunera

Recuperación de archivo de asentamientos en el INEGI Asentamientos humanos INEGI

Colonias https://www.inegi.org.mx/programas/dcah/

ruta<-"C:/Users/cguer/Documents/Claudia/Midropbox/Investigacion y escritos/karamanis/data/conjunto_de_datos/"
infile <- "00as.shp"
nomarchi<-as.filename(paste0(ruta,infile))
nomfil<-"00as"
a<-"SELECT * FROM \"00as\" WHERE (CVE_ENT = '05' OR CVE_ENT = '10') AND (CVE_MUN='035' OR CVE_MUN ='007' OR CVE_MUN='012')"
a<-"SELECT * FROM \"00as\" WHERE (CVE_ENT = '05' AND CVE_MUN = '035') OR (CVE_ENT='10' AND CVE_MUN ='007') OR (CVE_ENT='10' AND CVE_MUN='012')"

`%notin%` <- Negate(`%in%`)

datageot<- read_sf(nomarchi,options = "ENCODING=latin1",query=a)
#datageot<- read_sf(nomarchi,options = "ENCODING=latin1")
datageot= st_transform(datageot, crs = 4326)
#unique(datageot$TIPO)
#datageot<- datageot|> filter(NOM_ASEN %in% c("PROVIDENCIA","PROVIDENCIA CUARTA SECCIÓN","PROVIDENCIA QUINTA SECCIÓN","PROVIDENCIA SEGUNDA #SECCIÓN","PROVIDENCIA SUR","PROVIDENCIA TERCERA SECCIÓN","PRADOS PROVIDENCIA"))
#datageot<- datageot|> filter(NOM_ASEN %in% c("JARDINES DEL BOSQUE NORTE","JARDINES DEL BOSQUE CENTRO"))

unique(datageot$TIPO)

[1] “AEROPUERTO” “FRACCIONAMIENTO” “COLONIA”
[4] “ZONA INDUSTRIAL” “NINGUNO” “PUEBLO”
[7] “PARQUE INDUSTRIAL” “ZONA MILITAR” “RESIDENCIAL”
[10] “CONDOMINIO” “EJIDO” “UNIDAD HABITACIONAL” [13] “PRIVADA” “CIUDAD”

    datageot<- datageot|> filter(TIPO %notin% c("NINGUNO","CIUDAD"))


g <- ggplot() +
  #geom_sf(data = tor, fill = NA) +
  geom_sf(data = datageot, aes(fill = TIPO),alpha=.7) +
  scale_fill_manual(values = c("#f94144",
                               "#277da1",
                               "#277da1",
                               "#90be6d",
                               "#277da1",
                               "#f9a64f",
                               "#277da1",
                               "#9000ab",
                               "#277da1",
                               "#277da1",
                               "#f9a64f",
                               "#90beee",
                               "#577590",
                               "#f0028a"
                                         ))+

  labs(
    title = "Asentamientos humanos en La Laguna") +
  theme_minimal(
    base_family = "body_font",
    base_line_size = unit(0.1, "mm")
  ) +
  theme(
    legend.position = "bottom",
    legend.key.width = unit(3, "line"),
    legend.key.height = unit(0.5, "line"),
    plot.background = element_rect(fill = NA, color = NA),
    plot.title = element_text(size = 20,  hjust = 0.5, face = "bold"),
    plot.subtitle = element_text(size = 16,  hjust = 0.5),
    plot.caption = element_text(size = 10,  hjust = 0.5, margin = margin(20, 0, 0, 0))
    
  )


g

lim<-st_bbox(datageot)
#lim$ymax<-25.65
q <- opq(bbox = c(lim$xmin, lim$ymin, lim$xmax, lim$ymax))%>% 
  add_osm_feature(key = "highway") %>% 
  osmdata_sf()
qosm_sf <- q$osm_lines 
st_crs(qosm_sf) <-4326


qosm_sf <- qosm_sf|> filter(highway %in% c("primary","secondary"))


plot(qosm_sf$geometry)

sps <-  datageot%>%
  sf::st_coordinates() %>%
  as.data.frame() 

    sps<- sps|> filter(Y<=25.70)

sps <- 
  sps[c("X","Y")]


sps <- sps %>%
  st_as_sf(coords = c("X", "Y")) %>%
  summarize(geometry = st_union(geometry)) %>%
  st_convex_hull()

st_crs(sps) <- CRS("+proj=longlat +datum=WGS84 +no_defs")
bb <- sps %>% 
  pull(geometry) %>% 
  st_as_text()


# lectura de malla con SQL del asentamiento 


ruta<-"C:/Users/cguer/Documents/Claudia/Midropbox/Investigacion y escritos/karamanis/portraits/torreon/"
infile <- "malla_nivel10.gpkg"
nomarchi<-as.filename(paste0(ruta,infile))
geopackage = "nomarchi"

nomfil<-"n10_malla_rhealpix"
a<-glue("SELECT * FROM ", nomfil, " WHERE st_intersects(geom, st_polygonfromtext(")
c<-paste0(a,"'",bb,"' ))")
recorteosmlayer4<-read_sf(nomarchi, query = c)
#plot(recorteosmlayer4$geom)

g <- ggplot() +
  geom_sf(data = recorteosmlayer4, fill = NA) +

  labs(
    title = "Malla geoestadística nivel 10 de Guadalajara colonias 'Jardines del Bosque' "
  ) +
  theme_minimal(
    base_family = "body_font",
    base_line_size = unit(0.1, "mm")
  ) +
  theme(
    plot.title = element_text(size = 20)
  )
g

lim$ymax<-25.65

xlim <- c(lim$xmin,lim$xmax)
ylim <- c(lim$ymin,lim$ymax)

g <- ggplot() +
  geom_sf(data = recorteosmlayer4, fill = NA,alpha=0.1,linewidth=0.05,color="grey") +
    geom_sf(data = datageot, fill=NA,color="navy",linewidth = 0.5) +
      geom_sf(data = qosm_sf, color="red",fill = NA, linewidth = 0.1) +


  labs(
    title = "Malla geoestadística nivel 10 zona metropolitana de La Laguna"
  ) +
  theme_minimal(
    base_family = "body_font",
    base_line_size = unit(0.1, "mm")
  ) +
  theme(
    plot.title = element_text(size = 15)
  )+
  coord_sf(xlim = xlim, ylim = ylim)

g