Home

Awesome

geobr: Download Official Spatial Data Sets of Brazil

<img align="right" src="https://github.com/ipeaGIT/geobr/blob/master/r-package/man/figures/geobr_logo_b.png?raw=true" alt="logo" width="140"> <img align="right" src="https://github.com/ipeaGIT/geobr/blob/master/r-package/man/figures/geobr_logo_y.png?raw=true" alt="logo" width="140"> <p align="justify">geobr is a computational package to download official spatial data sets of Brazil. The package includes a wide range of geospatial data in geopackage format (like shapefiles but better), available at various geographic scales and for various years with harmonized attributes, projection and topology (see detailed list of available data sets below). </p>

The package is currently available in R and Python.

RPythonRepo
CRAN/METACRAN Version <br /> CRAN/METACRAN Total downloads <br /> CRAN/METACRAN downloads per month <br /> Codecov test coverage <br /> Lifecycle: stable <br /> R build statusPyPI version <br /> Downloads <br /> Downloads <br /> Lifecycle: maturing <br /> Python build status<img alt="GitHub stars" src="https://img.shields.io/github/stars/ipeaGIT/geobr.svg?color=orange"> <br /> <br /> Project Status: Active – The project has reached a stable, usable state and is being actively developed.

Installation R

# From CRAN
install.packages("geobr")
library(geobr)

# or use the development version with latest features
utils::remove.packages('geobr')
devtools::install_github("ipeaGIT/geobr", subdir = "r-package")
library(geobr)

obs. If you use Linux, you need to install a couple dependencies before installing the libraries sf and geobr. More info here.

Installation Python

pip install geobr

Windows users:

conda create -n geo_env
conda activate geo_env  
conda config --env --add channels conda-forge  
conda config --env --set channel_priority strict  
conda install python=3 geopandas  
pip install geobr

Basic Usage

The syntax of all geobr functions operate on the same logic so it becomes intuitive to download any data set using a single line of code. Like this:

R, reading the data as an sf object

library(geobr)

# Read specific municipality at a given year
mun <- read_municipality(code_muni=1200179, year=2017)

# Read all municipalities of given state at a given year
mun <- read_municipality(code_muni=33, year=2010) # or
mun <- read_municipality(code_muni="RJ", year=2010)

# Read all municipalities in the country at a given year
mun <- read_municipality(code_muni="all", year=2018)

More examples in the intro Vignette

Python, reading the data as a geopandas object

from geobr import read_municipality

# Read specific municipality at a given year
mun = read_municipality(code_muni=1200179, year=2017)

# Read all municipalities of given state at a given year
mun = read_municipality(code_muni=33, year=2010) # or
mun = read_municipality(code_muni="RJ", year=2010)

# Read all municipalities in the country at a given year
mun = read_municipality(code_muni="all", year=2018)

More examples here

Available datasets:

:point_right: All datasets use geodetic reference system "SIRGAS2000", CRS(4674).

FunctionGeographies availableYears availableSource
read_countryCountry1872, 1900, 1911, 1920, 1933, 1940, 1950, 1960, 1970, 1980, 1991, 2000, 2001, 2010, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020IBGE
read_regionRegion2000, 2001, 2010, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020IBGE
read_stateStates1872, 1900, 1911, 1920, 1933, 1940, 1950, 1960, 1970, 1980, 1991, 2000, 2001, 2010, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020IBGE
read_meso_regionMeso region2000, 2001, 2010, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020IBGE
read_micro_regionMicro region2000, 2001, 2010, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020IBGE
read_intermediate_regionIntermediate region2017, 2019, 2020IBGE
read_immediate_regionImmediate region2017, 2019, 2020IBGE
read_municipalityMunicipality1872, 1900, 1911, 1920, 1933, 1940, 1950, 1960, 1970, 1980, 1991, 2000, 2001, 2005, 2007, 2010, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022IBGE
read_municipal_seatMunicipality seats (sedes municipais)1872, 1900, 1911, 1920, 1933, 1940, 1950, 1960, 1970, 1980, 1991, 2010IBGE
read_weighting_areaCensus weighting area (área de ponderação)2010IBGE
read_census_tractCensus tract (setor censitário)2000, 2010, 2017, 2019, 2020IBGE
read_statistical_gridStatistical Grid of 200 x 200 meters2010IBGE
read_metro_areaMetropolitan areas1970, 2001, 2002, 2003, 2005, 2010, 2013, 2014, 2015, 2016, 2017, 2018IBGE
read_urban_areaUrban footprints2005, 2015IBGE
read_amazonBrazil's Legal Amazon2012MMA
read_biomesBiomes2004, 2019IBGE
read_conservation_unitsEnvironmental Conservation Units201909MMA
read_disaster_risk_areaDisaster risk areas2010CEMADEN and IBGE
read_indigenous_landIndigenous lands201907, 202103FUNAI
read_semiaridSemi Arid region2005, 2017IBGE
read_health_facilitiesHealth facilities201505, 202303CNES, DataSUS
read_health_regionHealth regions and macro regions1991, 1994, 1997, 2001, 2005, 2013DataSUS
read_neighborhoodNeighborhood limits2010IBGE
read_schoolsSchools2020, 2023INEP
read_comparable_areasHistorically comparable municipalities, aka Áreas mínimas comparáveis (AMCs)1872, 1900, 1911, 1920, 1933, 1940, 1950, 1960, 1970, 1980, 1991, 2000, 2010IBGE
read_urban_concentrationsUrban concentration areas (concentrações urbanas)2015IBGE
read_pop_arrangementsPopulation arrangements (arranjos populacionais)2015IBGE

Other functions:

FunctionAction
list_geobrList all datasets available in the geobr package
lookup_muniLook up municipality codes by their name, or the other way around
grid_state_correspondence_tableLoads a correspondence table indicating what quadrants of IBGE's statistical grid intersect with each state
cep_to_stateDetermine the state of a given CEP postal code
......

Note 1. Data sets and Functions marked with "dev" are only available in the development version of geobr.

Note 2. Most data sets are available at scale 1:250,000 (see documentation for details).

Coming soon:

GeographyYears availableSource
read_census_tract2007IBGE
Longitudinal Database* of micro regionsvarious yearsIBGE
Longitudinal Database* of Census tractsvarious yearsIBGE
.........

'*' Longitudinal Database refers to áreas mínimas comparáveis (AMCs)

Contributing to geobr

If you would like to contribute to geobr and add new functions or data sets, please check this guide to propose your contribution.


Related projects

As of today, there is another R package with similar functionalities: simplefeaturesbr. The geobr package has a few advantages when compared to simplefeaturesbr, including for example:

Similar packages for other countries/continents


Credits <img align="right" src="https://github.com/ipeaGIT/geobr/blob/master/r-package/man/figures/ipea_logo.png?raw=true" alt="ipea" width="300">

Original shapefiles are created by official government institutions. The geobr package is developed by a team at the Institute for Applied Economic Research (Ipea), Brazil. If you want to cite this package, you can cite it as: