| Type: | Package |
| Title: | Download Official Spatial Data Sets of Brazil |
| Version: | 2.0.0 |
| URL: | https://ipeagit.github.io/geobr/, https://github.com/ipeaGIT/geobr |
| BugReports: | https://github.com/ipeaGIT/geobr/issues |
| Description: | Easy access to official spatial data sets of Brazil. The package offers a wide range of spatial data sets available at various geographic scales and for various years with harmonized attributes, projection and fixed topology. All functions allow for seamless integration sf, DuckDB and Arrow. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| LazyData: | TRUE |
| Depends: | R (≥ 4.1.0) |
| Imports: | checkmate, cli, curl (≥ 5.0.0), dplyr (≥ 0.8-3), DBI, duckdb, duckspatial(≥ 1.1.0), fs, glue, httr2, methods, nanoarrow, piggyback, rlang, sf (≥ 0.9-3), sfheaders, stringr, utils |
| Suggests: | arrow (≥ 20.0.0), censobr (≥ 0.3.2), covr, data.table, geoarrow (≥ 0.4.2), ggplot2 (≥ 3.3.1), knitr, rmarkdown, scales, testthat |
| RoxygenNote: | 7.3.3 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2026-05-20 10:22:25 UTC; rafap |
| Author: | Rafael H. M. Pereira
|
| Maintainer: | Rafael H. M. Pereira <rafa.pereira.br@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-05-20 12:30:09 UTC |
geobr: Download Official Spatial Data Sets of Brazil
Description
Easy access to official spatial data sets of Brazil as 'sf' objects in R. The package includes a wide range of geospatial data available at various geographic scales and for various years with harmonized attributes, projection and fixed topology.
Usage
Please check the vignettes for more on the package usage:
Introduction to geobr (R) on the website.
Author(s)
Maintainer: Rafael H. M. Pereira rafa.pereira.br@gmail.com (ORCID)
Authors:
Rogério Jerônimo Barbosa
Other contributors:
Caio Nogueira Goncalves [contributor]
Cecilia do Lago [contributor]
Filipe Cavalcanti [contributor]
Arthur Bazolli [contributor]
Lucas Gelape [contributor]
Rafael Lopes [contributor]
Vinicius Oike [contributor]
Paulo Henrique Fernandes de Araujo [contributor]
Guilherme Duarte Carvalho [contributor]
Rodrigo Almeida de Arruda [contributor]
Igor Nascimento [contributor]
Barbara Santiago Pedreira da Costa [contributor]
Welligtton Silva Cavedo [contributor]
Pedro R. Andrade [contributor]
Alan da Silva [contributor]
Carlos Kauê Vieira Braga [contributor]
Carl Schmertmann [contributor]
Alessandro Samuel-Rosa [contributor]
Daniel Ferreira [contributor]
Marcus Saraiva [contributor]
Beatriz Milz (ORCID) [contributor]
ITpS - Instituto Todos pela Saúde [funder]
Ipea - Institue for Applied Economic Research [copyright holder, funder]
See Also
Useful links:
Report bugs at https://github.com/ipeaGIT/geobr/issues
Determine the state of a given CEP postal code
Description
Zips codes in Brazil are known as CEP, the abbreviation for postal code
address. CEPs in Brazil are 8 digits long, with the format 'xxxxx-xxx'.
Usage
cep_to_state(cep)
Arguments
cep |
A character string with 8 digits in the format |
Value
A character string with a state abbreviation.
Examples
uf <- cep_to_state(cep = '69900-000')
# Or:
uf <- cep_to_state(cep = '69900000')
Check internet connection with Ipea server
Description
Checks if there is an internet connection with Ipea server.
Usage
check_connection(
url = "https://github.com/ipea/geobr_prep_data/releases",
silent = FALSE
)
Arguments
url |
A string with the url address of an aop dataset |
silent |
Logical. Throw a message when silent is |
Value
Logical. TRUE if url is working, FALSE if not.
Support function to download metadata internally used in geobr
Description
Support function to download metadata internally used in geobr
Usage
download_metadata2()
Examples
## Not run: if (interactive()) {
df <- download_metadata2()
}
## End(Not run)
Download parquet to tempdir
Description
Download parquet to tempdir
Usage
download_parquet(
filename_to_download,
showProgress = parent.frame()$showProgress,
cache = parent.frame()$cache
)
Arguments
filename_to_download |
A string with the file name |
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
Filter data set to return specific states
Description
Filter data set to return specific states
Usage
filter_arrw(temp_arrw = parent.frame()$temp_arrw, code)
Arguments
temp_arrw |
An internal arrow table |
code |
The two-digit code of a state or a two-letter uppercase
abbreviation (e.g. 33 or "RJ"). If |
Value
A simple feature sf or data.frame.
Safely opens a Parquet file
Description
This function handles some failure modes, including if the Parquet file is corrupted.
Usage
geobr_open_dataset(filename)
Arguments
filename |
A local Parquet file |
Value
An duckspatial_df
A correspondence table indicating what quadrants of IBGE's statistical grid intersect with each Brazilian state
Description
Built-in dataset
-
name_state: Title-case name of state (character) -
abbrev_state: Two-letter uppercase abbreviation of a state -
code_grid: Unique code of each quadrant of IBGE's statistical grid
Usage
data(grid_state_correspondence_table)
Format
A data frame sf with 139 rows and 3 columns
Details
correspondence table indicating what quadrants of IBGE's statistical grid intersect with each Brazilian state
Note
Last updated 2021-o3-21
List all data sets available in the geobr package
Description
Returns a data frame with all data sets available in the geobr package
Usage
list_geobr(wide = TRUE)
Arguments
wide |
Whether the the output data frame should come in wide ( |
Value
A data.frame
Examples
df <- list_geobr()
Look up municipality codes and names
Description
Input a municipality name or code and get the names and codes of the municipality.
Usage
lookup_muni(year, name_muni = NULL, code_muni = NULL)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
name_muni |
The municipality name to be looked up. |
code_muni |
The municipality code to be looked up. |
Details
Only available from 2010 Census data so far
Value
A data.frame with 13 columns identifying the geographies information
of that municipality.
A data.frame
Examples
# Look for municipality Rio de Janeiro
mun <- lookup_muni(
name_muni = "Rio de Janeiro",
year = 2022
)
# Look for a given municipality code
mun <- lookup_muni(
code_muni = 3304557,
year = 2022
)
# Get the lookup table for all municipalities
mun_all <- lookup_muni(
name_muni = "all",
year = 2022
)
# Or:
mun_all <- lookup_muni(
code_muni = "all",
year = 2022
)
Check if vector only has numeric characters
Description
Checks if vector only has numeric characters
Usage
numbers_only(x)
Arguments
x |
A vector. |
Value
Logical. TRUE if vector only has numeric characters.
Download spatial data of Brazil's Legal Amazon
Description
This data set covers the whole of Brazil's Legal Amazon as defined in the federal law n. 12.651/2012). The original data comes from the Brazilian Ministry of Environment (MMA) and can be found at "http://mapas.mma.gov.br/i3geo/datadownload.htm".
Usage
read_amazon(
year,
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read Brazilian Legal Amazon
a <- read_amazon(year = 2024)
Download spatial data of Brazilian biomes
Description
This data set includes polygons of all biomes present in the Brazilian territory and coastal area. Data comes from IBGE. More information at https://www.ibge.gov.br/geociencias/cartas-e-mapas/informacoes-ambientais/15842-biomas.html
Usage
read_biomes(
year,
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read biomes
b <- read_biomes(year = 2025)
Download data of state capitals
Description
This function downloads either a spatial sf object with the location of the
municipal seats (sede dos municipios) of state capitals, or a data.frame
with the names and codes of state capitals. Data downloaded for the latest
available year.
Usage
read_capitals(output = "sf", showProgress = TRUE, cache = TRUE, verbose = TRUE)
Arguments
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read spatial data with the municipal seats of state capitals
capitals_sf <- read_capitals(output = "sf")
Download spatial data of census tracts
Description
Data of census tracts (setores censitários) of the Brazilian Population Census
Usage
read_census_tract(
year,
code_tract,
zone = "urban",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_tract |
The 7-digit code of a Municipality. If the two-digit code
or a two-letter uppercase abbreviation of a state is passed, (e.g. 33
or "RJ") the function will load all census tracts of that state. If
|
zone |
For census tracts before 2010, 'urban' and 'rural' census tracts are separate data sets. |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read all census tracts of a state at a given year
c <- read_census_tract(year = 2022, code_tract = "DF")
# Read all census tracts of a municipality at a given year
c <- read_census_tract(year = 2022, code_tract = 5201108)
# Read all census tracts of the country at a given year
c <- read_census_tract(year = 2022, code_tract = "all")
# Read rural census tracts for years before 2007
c <- read_census_tract(
year = 2000,
code_tract = 5201108,
zone = "rural"
)
Download spatial data of historically comparable municipalities
Description
This function downloads the shape file of minimum comparable area of
municipalities, known in Portuguese as 'Areas minimas comparaveis (AMCs)'.
The data is available for any combination of census years between 1872-2010.
These data sets are generated based on the Stata code originally developed by
Ehrl (2017) doi:10.1590/0101-416147182phe, and translated into R by the
geobr team.
Usage
read_comparable_areas(
start_year = 1970,
end_year = 2010,
simplified = TRUE,
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
start_year |
Numeric. Start year to the period in the YYYY format.
Defaults TO |
end_year |
Numeric. End year to the period in the YYYY format. Defaults
to |
simplified |
Logic |
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Details
These data sets are generated based on the original Stata code developed by Philipp Ehrl. If you use these data, please cite:
Ehrl, P. (2017). Minimum comparable areas for the period 1872-2010: an aggregation of Brazilian municipalities. Estudos Econômicos (São Paulo), 47(1), 215-229. https://doi.org/10.1590/0101-416147182phe
Value
An "sf" "data.frame" OR an ArrowObject
Examples
amc <- read_comparable_areas(start_year=1970, end_year=2010)
Download spatial data of Brazilian environmental conservation units
Description
This data set covers the whole of Brazil and it includes the polygons of all conservation units present in Brazilian territory. The original data and data dictionary can be found comes from MMA and can be found at "https://dados.mma.gov.br/dataset/unidadesdeconservacao".
Usage
read_conservation_units(
date,
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
date |
Numeric. Date of the data in YYYYMM format. It defaults to |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read conservation_units
uc <- read_conservation_units(date = 202503)
Download spatial data of Brazil's national borders
Description
National borders
Usage
read_country(
year,
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read specific year
br_1872 <- read_country(year = 1872)
br_2025 <- read_country(year = 2025)
Download spatial data of disaster risk areas
Description
This function reads the the official data of disaster risk areas in Brazil (currently only available for 2010). It specifically focuses on geodynamic and hydro-meteorological disasters capable of triggering landslides and floods. The data set covers the whole country. Each risk area polygon (known as 'BATER') has unique code id (column 'geo_bater'). The data set brings information on the extent to which the risk area polygons overlap with census tracts and block faces (column "acuracia") and number of ris areas within each risk area (column 'num'). Original data were generated by IBGE and CEMADEN. For more information about the methodology, see deails at https://www.ibge.gov.br/geociencias/organizacao-do-territorio/tipologias-do-territorio/21538-populacao-em-areas-de-risco-no-brasil.html
Usage
read_disaster_risk_area(
year,
code_muni = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_muni |
The 7-digit code of a municipality. If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read all disaster risk areas in an specific year
d <- read_disaster_risk_area(year = 2010)
# Read disaster risk areas in a given municipality
d <- read_disaster_risk_area(year = 2010, code_muni = 2927408)
# Read disaster risk areas in a given state
d <- read_disaster_risk_area(year = 2010, code_muni = "AC")
Download spatial data of favelas and urban communities
Description
This function reads the official data on favelas and urban communities (favelas e comunidades urbanas) of Brazil. Original data from the Institute of Geography and Statistics (IBGE) For more information about the methodology, see details at https://biblioteca.ibge.gov.br/visualizacao/livros/liv102134.pdf
Usage
read_favela(
year,
code_muni = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_muni |
The 7-digit code of a municipality. If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read all favelas of Brazil
n <- read_favela(year = 2022)
# Read all favelas of a given municipality
n <- read_favela(year = 2022, code_muni = 2927408)
# Read all favelas of a given state
n <- read_favela(year = 2022, code_muni = "RJ")
Download geolocated data of health facilities
Description
Data comes from the National Registry of Health Facilities (Cadastro
Nacional de Estabelecimentos de Saude - CNES), originally collected by the
Brazilian Ministry of Health.
The spatial coordinates used in geobr are a combination of the coordinates
produced by the original data producer and the coordinates found via geocoding
with the geocodebr package https://CRAN.R-project.org/package=geocodebr.
Whenever the distance between the coordinates from both sources is smaller than
800 meters, geobr uses coordinates from the data producer. When the distance
between the two sources is greater than 800 meters and the results from
geocodebr have a precision level finer than 800 meters, geobr uses the
coordinates from geocodebr. When the coordinates from the original source are
missing, geobr also uses geocodebr coordinates, regardless of precision level.
The source of the spatial coordinates used in each observation is registered
in the data in a specific column coords_source. Additional columns
indicating the precision level of geocodebr geocoding are also included in
the data.
Usage
read_health_facilities(
date,
code_muni = "all",
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
date |
Numeric. Date of the data in YYYYMM format. It defaults to |
code_muni |
The 7-digit code of a municipality. If |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read health facilities of a given state
h <- read_health_facilities(
date = 202601,
code_muni = "PA"
)
# Read all health facilities of the whole country
h <- read_health_facilities(date = 202601)
Download spatial data of Brazilian health regions and health macro regions
Description
Health regions are used to guide the the regional and state planning of health services. Macro health regions, in particular, are used to guide the planning of high complexity #' health services. These services involve larger economics of scale and are concentrated in few municipalities because they are generally more technology intensive, costly and face shortages of specialized professionals. A macro region comprises one or more health regions.
Usage
read_health_region(
year,
code_state = "all",
geometry_level = "municipality",
macro = NULL,
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_state |
The two-digit code of a state or a two-letter uppercase
abbreviation (e.g. 33 or "RJ"). If |
geometry_level |
String. Spatial level of the output geometries. Use
|
macro |
The argument |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read municipalities with info on health regions
health_muni <- read_health_region(year = 2024)
# Read the geometries of micro regions
health_micro <- read_health_region(
year = 2024,
geometry_level = "micro"
)
# Read the geometries of macro regions
health_macro <- read_health_region(
year = 2024,
geometry_level = "macro"
)
Download spatial data of Brazil's Immediate Geographic Areas
Description
The Immediate Geographic Areas are part of the geographic division of Brazil created after 2017 by IBGE. These regions were created to replace the "Micro Regions" division. Data at scale 1:250,000.
Usage
read_immediate_region(
year,
code_immediate = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_immediate |
6-digit code of an immediate region. If the two-digit
code or a two-letter uppercase abbreviation of a state is passed, (e.g.
33 or "RJ") the function will load all immediate regions of that state.
If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read an specific immediate region
im <- read_immediate_region(code_immediate=110006, year = 2024)
# Read immediate regions of a state
im <- read_immediate_region(code_immediate="AM", year = 2024)
im <- read_immediate_region(code_immediate=12, year = 2024)
# Read all immediate regions of the country
im <- read_immediate_region(code_immediate="all", year = 2024)
Download spatial data of indigenous lands in Brazil
Description
The data set covers the whole of Brazil and it includes indigenous lands from all ethnic groups and at different stages of demarcation. The original data comes from the National Indian Foundation (FUNAI) and can be found at https://www.gov.br/funai/pt-br/atuacao/terras-indigenas/geoprocessamento-e-mapas. Although original data is updated monthly, the geobr package will only keep the data for a few months per year.
Usage
read_indigenous_land(
year,
code_state = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_state |
The two-digit code of a state or a two-letter uppercase
abbreviation (e.g. 33 or "RJ"). If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read all indigenous land in an specific year
i <- read_indigenous_land(year = 2025)
Download spatial data of Brazil's Intermediate Geographic Areas
Description
The intermediate Geographic Areas are part of the geographic division of Brazil created after 2017 by IBGE. These regions were created to replace the "Meso Regions" division. Data at scale 1:250,000.
Usage
read_intermediate_region(
year,
code_intermediate = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_intermediate |
4-digit code of an intermediate region. If the
two-digit code or a two-letter uppercase abbreviation of a state is
passed, (e.g. 33 or "RJ") the function will load all intermediate
regions of that state. If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read an specific intermediate region
inter <- read_intermediate_region(code_intermediate = 1202, year = 2024)
# Read intermediate regions of a state
inter <- read_intermediate_region(code_intermediate = "AM", year = 2024)
inter <- read_intermediate_region(code_intermediate = 12, year = 2024)
# Read all intermediate regions of the country
inter <- read_intermediate_region(code_intermediate = "all", year = 2024)
Download spatial data of meso regions
Description
Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674)
Usage
read_meso_region(
year,
code_meso = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_meso |
The 4-digit code of a meso region. If the two-digit code or
a two-letter uppercase abbreviation of a state is passed, (e.g. 33 or
"RJ") the function will load all meso regions of that state. If
|
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read specific meso region at a given year
meso <- read_meso_region(code_meso=3301, year = 2018)
# Read all meso regions of a state at a given year
meso <- read_meso_region(code_meso="AM", year = 2018)
meso <- read_meso_region(code_meso=12, year = 2018)
# Read all meso regions of the country at a given year
meso <- read_meso_region(code_meso="all", year = 2018)
Download spatial data of official metropolitan areas in Brazil
Description
The function returns the shapes of municipalities grouped by their respective metro areas. Metropolitan areas are created by each state in Brazil. The data set includes the municipalities that belong to all metropolitan areas in the country according to state legislation in each year. Original data were generated by the Brazilian Institute of Geography and Statistics (IBGE). Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674).
Usage
read_metro_area(
year,
code_state = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_state |
The two-digit code of a state or a two-letter uppercase
abbreviation (e.g. 33 or "RJ"). If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read all official metropolitan areas for a given year
m <- read_metro_area(year = 1970)
m <- read_metro_area(
year = 2024,
code_state = "RJ"
)
Download spatial data of micro regions
Description
Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674)
Usage
read_micro_region(
year,
code_micro = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_micro |
5-digit code of a micro region. If the two-digit code or a
two-letter uppercase abbreviation of a state is passed, (e.g. 33 or
"RJ") the function will load all micro regions of that state. If
|
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read an specific micro region a given year
micro <- read_micro_region(code_micro=11008, year=2018)
# Read micro regions of a state at a given year
micro <- read_micro_region(code_micro="AM", year=2018)
micro <- read_micro_region(code_micro=12, year=2018)
# Read all micro regions at a given year
micro <- read_micro_region(code_micro="all", year=2018)
Download spatial data of municipal seats (sede dos municipios) of Brazil
Description
This function reads the official data on the municipal seats (sede dos municipios) of Brazil. The data brings the geographical coordinates (lat lon) of municipal seats for various years since 1872. Original data by the Brazilian Institute of Geography and Statistics (IBGE).
Usage
read_municipal_seat(
year,
code_muni = "all",
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_muni |
The 7-digit code of a municipality. If |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read municipal seats in an specific year
m <- read_municipal_seat(year = 2022)
Download spatial data of Brazilian municipalities
Description
Brazilian municipalities
Usage
read_municipality(
year,
code_muni = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE,
keep_areas_operacionais = FALSE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_muni |
The 7-digit code of a municipality. If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
keep_areas_operacionais |
Logic. Whether the function should keep the
polygons of Lagoas dos Patos and Lagoa Mirim in the State of Rio Grande
do Sul (considered as areas estaduais operacionais). Defaults to |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read specific municipality at a given year
mun <- read_municipality(code_muni = 1200179, year = 2017)
# Read all municipalities of a state at a given year
mun <- read_municipality(code_muni = 33, year = 2010)
mun <- read_municipality(code_muni = "RJ", year = 2010)
# Read all municipalities of the country at a given year
mun <- read_municipality(code_muni = "all", year = 2018)
Download spatial data of neighborhood limits of Brazilian municipalities
Description
This data set includes the neighborhood limits of Brazilian municipalities. The data is only available for those municipalities where neighborhood information was collected in the population census. The data set is based on aggregations of the census tracts from the Brazilian census.
Usage
read_neighborhood(
year,
code_muni = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_muni |
The 7-digit code of a municipality. If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read neighborhoods of Brazilian municipalities
n <- read_neighborhood(year = 2022)
# Read neighborhoods of two municipalities, Recife and Porto Alegre in this example
r <- read_neighborhood(
year = 2022,
code_muni = c(2611606, 4314902)
)
Download geolocated data of polling places
Description
Data comes from the Superior Electoral Court (TSE).
The spatial coordinates used in geobr are a combination of the coordinates
produced by the original data producer and the coordinates found via geocoding
with the geocodebr package https://CRAN.R-project.org/package=geocodebr.
Whenever the distance between the coordinates from both sources is smaller than
800 meters, geobr uses coordinates from the data producer. When the distance
between the two sources is greater than 800 meters and the results from
geocodebr have a precision level finer than 800 meters, geobr uses the
coordinates from geocodebr. When the coordinates from the original source are
missing, geobr also uses geocodebr coordinates, regardless of precision level.
The source of the spatial coordinates used in each observation is registered
in the data in a specific column coords_source. Additional columns
indicating the precision level of geocodebr geocoding are also included in
the data.
Usage
read_polling_places(
year,
code_muni = "all",
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_muni |
The 7-digit code of a municipality. If |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read health facilities of a given municipality
h <- read_polling_places(
year = 2022,
code_muni = 2800308
)
# Read health facilities of a given state
h <- read_polling_places(
year = 2022,
code_muni = "SE"
)
# Read all health facilities of the whole country
h <- read_polling_places(year = 2022)
Download population arrangements in Brazil
Description
This function reads the official data on the population arrangements (Arranjos Populacionais) in Brazil. Original data by the Brazilian Institute of Geography and Statistics (IBGE). More information about the methodology at https://www.ibge.gov.br/geociencias/organizacao-do-territorio/divisao-regional/15782-arranjos-populacionais-e-concentracoes-urbanas-do-brasil.html
Usage
read_pop_arrangements(
year,
code_state = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_state |
The two-digit code of a state or a two-letter uppercase
abbreviation (e.g. 33 or "RJ"). If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read population arrangements in an specific year
pa <- read_pop_arrangements(year = 2010)
Download spatial data of quilombola lands in Brazil
Description
Read data of quilombola areas officialy recognized by the Instituto Nacional
de Colonização e Reforma Agrária - INCRA. The date refers to the date when
the data was downloaded, and captures the quilombola lands recognized on that
date. More info at https://dados.gov.br/dados/conjuntos-dados/comunidades-quilombolas-certificadas.
Usage
read_quilombola_land(
date,
code_state = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
date |
Numeric. Date of the data in YYYYMM format. It defaults to |
code_state |
The two-digit code of a state or a two-letter uppercase
abbreviation (e.g. 33 or "RJ"). If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Data dictionary
-
code_quilombo- Código da Comunidade Quilombola (para controle interno) -
name_quilombo- Nome da Comunidade Quilombola -
code_sr- Código da Superintendência Regional -
n_process- Número do processo de titulação de terras, junto ao Instituto Nacional de Colonização e Reforma Agrária - INCRA -
name_muni- Nome do Município em que está localizada -
abbrev_state- Sigla da Unidade Federativa em que está localizada -
code_state- Código da Unidade Federativa em que está localizada -
date_recog- Data de publicação da portaria de reconhecimento pelo presidente do INCRA -
date_decree_pr- Decreto da presidência da República para fins de desapropriação, por interesse social -
date_decree- Data decreto de regularização do território -
date_titulacao- Data da titulação das terras -
code_sipra- Código no Sistema de Informações de Projetos de Reforma Agrária - SIPRA -
n_family- Número de famílias -
perimeter- Perímetro calculado depois da medição/demarcação (georreferenciamento) para fins de certificação -
area_ha- Área em hectares -
geo_scale- Escala utilizada para mapeamento -
stage- Fase do processo -
gov_level- Nível da esfera administrativa responsável -
responsible_unit- Órgão responsável
Examples
# Read all quilombola areas in an specific date
q <- read_quilombola_land(date = 202605)
# Read the quilombola areas in an given state
ba <- read_quilombola_land(date = 202605, code_state = "BA")
Download spatial data of Brazil Regions
Description
Brazil macro regions
Usage
read_region(
year,
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read specific year
reg <- read_region(year = 2023)
Download geolocated data of schools
Description
Data comes from the School Census and Catalogue of Schools, organized by the
National Institute for Educational Studies and Research Anisio Teixeira (INEP).
More information available at https://www.gov.br/inep/pt-br/acesso-a-informacao/dados-abertos/inep-data/catalogo-de-escolas/.
The spatial coordinates used in geobr are a combination of the coordinates
produced by the original data producer and the coordinates found via geocoding
with the geocodebr package https://CRAN.R-project.org/package=geocodebr.
Whenever the distance between the coordinates from both sources is smaller than
800 meters, geobr uses coordinates from the data producer. When the distance
between the two sources is greater than 800 meters and the results from
geocodebr have a precision level finer than 800 meters, geobr uses the
coordinates from geocodebr. When the coordinates from the original source are
missing, geobr also uses geocodebr coordinates, regardless of precision level.
The source of the spatial coordinates used in each observation is registered
in the data in a specific column coords_source. Additional columns
indicating the precision level of geocodebr geocoding are also included in
the data.
Usage
read_schools(
year,
code_muni = "all",
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_muni |
The 7-digit code of a municipality. If |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read all schools in the country
s <- read_schools(year = 2020)
# Read all schools in a given state
s <- read_schools(
year = 2020,
code_muni = "AC"
)
# Read all schools in a given municipality
s <- read_schools(
year = 2020,
code_muni = 1200401
)
Download spatial data of the Brazilian Semiarid region
Description
This data set returns all the municipalities which are legally included in the Brazilian Semiarid, following changes in the national legislation. The original data comes from the Brazilian Institute of Geography and Statistics (IBGE) and can be found at https://www.ibge.gov.br/geociencias/cartas-e-mapas/mapas-regionais/15974-semiarido-brasileiro.html
Usage
read_semiarid(
year,
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# read Brazilian semiarid
sa <- read_semiarid(year = 2022)
Download spatial data of Brazilian states
Description
Brazilian states
Usage
read_state(
year = NULL,
code_state = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_state |
The two-digit code of a state or a two-letter uppercase
abbreviation (e.g. 33 or "RJ"). If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read all states at a given year
ufs <- read_state(code_state="all", year = 2025)
# Read specific state at a given year
uf <- read_state(code_state="SC", year = 2025)
# Read specific state at a given year
uf <- read_state(code_state=12, year = 2025)
Download spatial data of IBGE's statistical grid
Description
Official gridded population estimate of Brazil.
Usage
read_statistical_grid(
year,
code_muni,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_muni |
The 7-digit code of a municipality. If |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read the grid covering a given state at a given year
grid_rio <- read_statistical_grid(
year = 2022,
code_muni = "RJ"
)
# Read the grid covering a given municipality at a given year
grid_ssalvador <- read_statistical_grid(
year = 2022,
code_muni = 2927408
)
Download spatial data of urbanized areas in Brazil
Description
This function reads the official data on the urban footprint of Brazilian cities. Original data by the Brazilian Institute of Geography and Statistics (IBGE) For more information about the methodology, see details at https://biblioteca.ibge.gov.br/visualizacao/livros/liv100639.pdf
Usage
read_urban_area(
year,
code_muni = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_muni |
The 7-digit code of a municipality. If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read urban footprint of Brazilian cities in an specific year
d <- read_urban_area(year = 2015)
Download urban concentration areas in Brazil
Description
This function reads the official data on the urban concentration areas (Áreas de Concentração de População) in Brazil. Original data by the Brazilian Institute of Geography and Statistics (IBGE). More information about the methodology at https://www.ibge.gov.br/geociencias/organizacao-do-territorio/divisao-regional/15782-arranjos-populacionais-e-concentracoes-urbanas-do-brasil.html
Usage
read_urban_concentrations(
year,
code_state = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_state |
The two-digit code of a state or a two-letter uppercase
abbreviation (e.g. 33 or "RJ"). If |
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read urban concentration areas in an specific year
uc <- read_urban_concentrations(year = 2010)
Download spatial data of census weighting areas
Description
Data of Census Weighting Areas (area de ponderação) of the Brazilian Population Census
Usage
read_weighting_area(
year,
code_weighting = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE
)
Arguments
year |
Numeric. Year of the data in YYYY format. It defaults to |
code_weighting |
The 7-digit code of a Municipality. If the two-digit code
or a two-letter uppercase abbreviation of a state is passed, (e.g. 33 or "RJ")
the function will load all weighting areas of that state. If
|
simplified |
Logic |
output |
String. Type of object returned by the function. Defaults to
|
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read the data cached
locally, which is faster. Defaults to |
verbose |
A logical. If |
Value
An "sf" "data.frame" OR an ArrowObject
Examples
# Read specific weighting area at a given year
w <- read_weighting_area(
code_weighting = 5201108005004,
year = 2010
)
# Read all weighting areas of a state at a given year
w <- read_weighting_area(
code_weighting = "DF",
year = 2010
)
# Read all weighting areas of a municipality at a given year
w <- read_weighting_area(
code_weighting = 5201108,
year = 2010
)
# Read all weighting areas of the country at a given year
w <- read_weighting_area(
code_weighting = "all",
year = 2010
)
Remove islands from Brazil
Description
Removes Brazilian islands that are approximately more than 20 km from the mainland coast. This is useful when analyses or data visualization should focus on the continental territory of Brazil and exclude distant oceanic islands.
Usage
remove_islands(x)
Arguments
x |
An 'sf' object with CRS EPSG:4674. Usually an object returned from
other geobr functions, such as |
Value
An sf data frame with the same attributes as x, but with distant
islands removed from the geometry.
Examples
library(geobr)
library(sf)
br <- read_country(year = 1991)
br_no_islands <- remove_islands(br)
plot(br)
Select data type: 'original' or 'simplified' (default)
Description
Select data type: 'original' or 'simplified' (default)
Usage
select_geometry_type(temp_meta, simplified_geometry)
Arguments
temp_meta |
A data.frame with the metadata of geobr datasets |
simplified_geometry |
Logical |
Select metadata
Description
Select metadata
Usage
select_metadata(
geography,
year = parent.frame()$year,
simplified = parent.frame()$simplified,
verbose = parent.frame()$verbose
)
Arguments
geography |
Which geography will be downloaded. |
year |
Year of the dataset (passed by read_ function). |
simplified |
Logical TRUE or FALSE indicating whether the function returns the 'original' dataset with high resolution or a dataset with 'simplified' borders (Defaults to TRUE). |
Examples
## Not run: if (interactive()) {
library(geobr)
df <- download_metadata()
}
## End(Not run)
Select year input
Description
Select year input
Usage
select_year_input(
temp_meta,
y = parent.frame()$year,
verbose = parent.frame()$verbose
)
Arguments
temp_meta |
A dataframe with the file_url addresses of geobr datasets |
y |
Year of the dataset (passed by red_ function) |
verbose |
A logical. If |