GeoQuetzal gives researchers programmatic access to Guatemala’s administrative boundaries and 2018 Census microdata (INE), following the same philosophy as tidycensus for the US and geobr for Brazil.
What is GeoQuetzal?
GeoQuetzal brings together three things that normally require manual work:
Administrative boundaries: 22 departments and 340 municipalities with correct INE codes, ready to join with any dataset that uses the same codes for departments and municipalities.
Census microdata: persons, households, housing units, and emigration from the 2018 Census, partitioned by department for efficient downloads. Data can be load at level of departments or municipalities.
Sub-municipal data: 20,254 lugares poblados with pre-aggregated indicators for demographics, ethnicity, education, housing, and services.
GeoQuetzal enables the analysis and visualization of the census variables at the country, department, and municipality levels. The geographical analysis offers more detailed, immersive, and comprehensive results. Example, What is Guatemala’s Internet access rate? Hover over each area to see the locality name and percentage.
import geoquetzal as gq# Administrative boundaries, instant loading, no Internet requireddeptos = gq.departamentos()# Microdatos censalesdf = gq.hogares() #Downloads all departments data, it might take some time depending on the Internet speed
⬇ Descargando hogares para los 22 departamentos...
✓ 3,275,931 hogares cargados
# % of households with Internet per departmentacceso_internet = ( df.groupby("DEPARTAMENTO")["PCH9_I"] .apply(lambda x: (x ==1).mean() *100) .round(1) .reset_index(name="pct_internet"))#Join geometry, visualizationresultado = deptos.merge(acceso_internet, left_on="codigo_depto", right_on="DEPARTAMENTO")resultado.explore( column="pct_internet", cmap="YlGnBu", tooltip=["departamento", "pct_internet"], tooltip_kwds={"aliases": ["Departamento", "% Internet"]}, tiles="CartoDB positron", style_kwds={"weight": 1, "color": "white", "fillOpacity": 0.8},)
Make this Notebook Trusted to load map: File -> Trust Notebook
if (!requireNamespace("geoquetzal", quietly =TRUE)) { remotes::install_github("geoquetzal/geoquetzal-r")}library(geoquetzal)library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
library(mapview)# Administratives boundaries, instant loading, no Internet access requireddeptos <-departamentos()#Census microdatadf <-hogares() # All the departments
⬇ Descargando hogar para los 22 departamentos...
⬇ Descargando hogar depto 01 (Guatemala)...
⬇ Descargando hogar depto 02 (El Progreso)...
⬇ Descargando hogar depto 03 (Sacatepéquez)...
⬇ Descargando hogar depto 04 (Chimaltenango)...
⬇ Descargando hogar depto 05 (Escuintla)...
⬇ Descargando hogar depto 06 (Santa Rosa)...
⬇ Descargando hogar depto 07 (Sololá)...
⬇ Descargando hogar depto 08 (Totonicapán)...
⬇ Descargando hogar depto 09 (Quetzaltenango)...
⬇ Descargando hogar depto 10 (Suchitepéquez)...
⬇ Descargando hogar depto 11 (Retalhuleu)...
⬇ Descargando hogar depto 12 (San Marcos)...
⬇ Descargando hogar depto 13 (Huehuetenango)...
⬇ Descargando hogar depto 14 (Quiché)...
⬇ Descargando hogar depto 15 (Baja Verapaz)...
⬇ Descargando hogar depto 16 (Alta Verapaz)...
⬇ Descargando hogar depto 17 (Petén)...
⬇ Descargando hogar depto 18 (Izabal)...
⬇ Descargando hogar depto 19 (Zacapa)...
⬇ Descargando hogar depto 20 (Chiquimula)...
⬇ Descargando hogar depto 21 (Jalapa)...
⬇ Descargando hogar depto 22 (Jutiapa)...
✓ 3,275,931 registros cargados
# % of households with Internet access per departmentacceso_internet <- df |>group_by(DEPARTAMENTO) |>summarise(pct_internet =round(mean(PCH9_I ==1, na.rm =TRUE) *100, 1))# Merge with geometry, visualizationresultado <-merge(deptos, acceso_internet,by.x ="codigo_depto", by.y ="DEPARTAMENTO")mapview(resultado,zcol ="pct_internet",layer.name ="% Internet",col.regions = RColorBrewer::brewer.pal(9, "YlGnBu"),map.types ="CartoDB.Positron",label ="departamento")
Warning: Found less unique colors (9) than unique zcol values (19)!
Interpolating color vector to match number of zcol values.
import geoquetzal as gq# Administrative boundaries — instant load, no internet neededdeptos = gq.departamentos()# Census microdata — downloads only the department you needdf = gq.hogares(departamento="Sacatepequez")# % of households with internet per municipalityacceso_internet = ( df.groupby("MUNICIPIO")["PCH9_I"] .apply(lambda x: (x ==1).mean() *100) .round(1) .reset_index(name="pct_internet"))# Join with geometry and visualizemunis = gq.municipios("Sacatepequez")resultado = munis.merge(acceso_internet, left_on="codigo_muni", right_on="MUNICIPIO")resultado.explore( column="pct_internet", cmap="YlGnBu", tooltip=["municipio", "pct_internet"], tooltip_kwds={"aliases": ["Municipality", "% Internet"]}, tiles="CartoDB positron", style_kwds={"weight": 1, "color": "white", "fillOpacity": 0.8},)
Make this Notebook Trusted to load map: File -> Trust Notebook
if (!requireNamespace("geoquetzal", quietly =TRUE)) { remotes::install_github("geoquetzal/geoquetzal-r")}library(geoquetzal)library(dplyr)library(mapview)# Administratives boundaries, instant loading, no Internet access requiredmunicipios <-municipios()# Census microdata for Sacatepequezdf <-hogares("Sacatepéquez") # Departament of Sacatepéquez
⬇ Descargando hogar depto 03 (Sacatepéquez)...
# % of households with Internet access per departmentacceso_internet <- df |>group_by(MUNICIPIO) |>summarise(pct_internet =round(mean(PCH9_I ==1, na.rm =TRUE) *100, 1))# Merge with geometry, visualizationresultado <-merge(municipios, acceso_internet,by.x ="codigo_muni", by.y ="MUNICIPIO")mapview(resultado,zcol ="pct_internet",layer.name ="% Internet",col.regions = RColorBrewer::brewer.pal(9, "YlGnBu"),map.types ="CartoDB.Positron",label ="municipio")
Warning: Found less unique colors (9) than unique zcol values (16)!
Interpolating color vector to match number of zcol values.