| Title: | Data from the 'Access to Opportunities Project (AOP)' |
| Version: | 1.2.0 |
| Description: | Download data from the 'Access to Opportunities Project (AOP)'. The 'aopdata' package brings annual estimates of access to employment, health, education and social assistance services by transport mode, as well as data on the spatial distribution of population, jobs, health care, schools and social assistance facilities at a fine spatial resolution for all cities included in the project. More info on the 'AOP' website https://www.ipea.gov.br/acessooportunidades/en/. |
| URL: | https://ipea.github.io/aopdata/, https://github.com/ipea/aopdata |
| BugReports: | https://github.com/ipea/aopdata/issues |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.1.0) |
| Imports: | cli (≥ 3.0.0), checkmate, curl (≥ 5.0.0), data.table, httr2 (≥ 1.2.0), methods, rlang (≥ 1.0.0), sf (≥ 0.9-3), utils |
| Suggests: | covr, dplyr (≥ 0.8-3), ggplot2 (≥ 3.3.1), knitr, rmarkdown (≥ 2.30), scales, testthat (≥ 3.1.7), units |
| VignetteBuilder: | knitr |
| Config/roxygen2/version: | 8.1.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-10-19 03:12:20 UTC; rafap |
| Author: | Rafael H. M. Pereira
|
| Maintainer: | Rafael H. M. Pereira <rafa.pereira.br@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-10-19 08:40:02 UTC |
aopdata: Data from the 'Access to Opportunities Project (AOP)'
Description
Download data from the 'Access to Opportunities Project (AOP)'. The aopdata package brings annual estimates of access to employment, health, education and social assistance services by transport mode, as well as data on the spatial distribution of population, jobs, health care, schools and social assistance facilities at a fine spatial resolution for all cities included in the project. More info on the AOP website https://www.ipea.gov.br/acessooportunidades/en/.
Usage
Please check the vignettes on the website.
Author(s)
Maintainer: Rafael H. M. Pereira rafa.pereira.br@gmail.com (ORCID)
Authors:
Rafael H. M. Pereira rafa.pereira.br@gmail.com (ORCID)
Daniel Herszenhut dhersz@gmail.com (ORCID)
Marcus Saraiva marcus.saraiva@gmail.com (ORCID)
Carlos Kaue Vieira Braga kaue@kauebraga.dev (ORCID)
Other contributors:
Diego Bogado Tomasiello diegobt86@gmail.com [contributor]
Joao Bazzo joao.bazzo@gmail.com [contributor]
Ipea - Institute for Applied Economic Research [copyright holder, funder]
See Also
Useful links:
Report bugs at https://github.com/ipea/aopdata/issues
Throw an aopdata error when a checkmate check fails
Description
Throw an aopdata error when a checkmate check fails
Usage
abort_if_invalid(check, arg, call = rlang::caller_env())
Arguments
check |
Result of a |
arg |
Name of the argument being checked. |
call |
Environment of the call shown in the error. |
Value
invisible(TRUE), or an error of class aopdata_error.
Download files in parallel
Description
The only function in the package that downloads data files.
Usage
aop_fetch(urls, paths, progress = FALSE, label = "Downloading files")
Arguments
urls |
Character. Urls of the files. |
paths |
Character. Where to save each file. |
progress |
Logical. Show a progress bar: of downloaded data when there is a single file, of the number of files otherwise. |
label |
Character. Name of the progress bar of files. |
Value
A character vector with one status per file (see classify_resp()).
Merge land use and access data
Description
Merges landuse and access data
Usage
aop_merge(aop_landuse, aop_access)
Arguments
aop_landuse |
A |
aop_access |
A |
Value
Returns a data.table with landuse and access data
Build a download request
Description
Build a download request
Usage
aop_request(url)
Arguments
url |
A string with the url address of a file. |
Value
An httr2_request. curl's 10 s connect timeout is kept, a
transfer slower than 1 kB/s for 30 s is aborted, and nothing is
retried automatically (the mirror is the retry).
Spatial join of AOP data
Description
Merges land use or access data with H3 grid geometries
Usage
aop_spatial_join(aop_df, aop_sf)
Arguments
aop_df |
A |
aop_sf |
A spatial |
Value
Returns a data.frame sf with access/land use data and grid geometries
aopdata data dictionary
Description
Opens aopdata data dictionary on a web browser. This function requires internet connection.
Usage
aopdata_dictionary(lang = "en")
Arguments
lang |
Character. Language of data dictionary. It can be either |
Value
Opens aopdata data dictionary on a web browser
Examples
# Data dictionary in English
aopdata_dictionary(lang='en')
# Data dictionary in Portuguese
aopdata_dictionary(lang='pt')
Check internet connection with Ipea server
Description
Checks if there is an internet connection with Ipea server.
Usage
check_connection(
url = "https://www.ipea.gov.br/geobr/aopdata/metadata/metadata.csv",
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.
Classify the result of one download
Description
Classify the result of one download
Usage
classify_resp(x)
Arguments
x |
A response, an error condition, or |
Value
One of "ok", "http_error", "conn_error" or "aborted".
Download data to a temporary directory.
Description
Downloads the requested files to a temporary directory (the session cache) and reads them. Each file is downloaded from the Ipea server first and, if that fails, from the GitHub release mirror.
Usage
download_data(url, progress_bar)
Arguments
url |
A string with the url address of aop dataset |
progress_bar |
Logical. Whether to display a progress bar. |
Value
An sf or a data.frame, or NULL (with a message) if any file
could not be downloaded or read.
Support function to download metadata internally used in aopdata
Description
Downloads metadata.csv from the GitHub release or, if that
fails, from the Ipea server, and caches it in tempdir() for
the session. A file is cached only once it has been read
successfully; a cached file that can't be read is downloaded
again.
Usage
download_metadata()
Value
A data.table with the metadata, or NULL (with a message) if it
could not be downloaded.
Examples
## Not run: if (interactive()) {
df <- download_metadata()
}
## End(Not run)
Inform the user that a download failed
Description
Inform the user that a download failed
Usage
inform_failure(msg)
Arguments
msg |
The message text. |
Value
Signals a message of class aopdata_network.
Load data from tempdir to global environment
Description
Reads data from tempdir to global environment.
Usage
load_data(temps)
Arguments
temps |
The paths of one or more data files stored in tempdir, all
|
Value
Returns either an sf or a data.frame, depending of the data set
that was downloaded
Download accessibility estimates with population and land use data
Description
Download estimates of access to employment, health, education and social assistance services by transport mode and time of the day for the cities included in the AOP project. See the documentation 'Details' for the data dictionary. The data set reports information for each hexagon in a H3 spatial grid at resolution 9, with a side of 174 meters and an area of 0.10 km2. More information about H3 at https://h3geo.org/docs/core-library/restable/.
Usage
read_access(
city = NULL,
mode = "walk",
peak = TRUE,
year = 2019,
geometry = FALSE,
showProgress = TRUE
)
Arguments
city |
Character. A city name or three-letter abbreviation. If
|
mode |
Character. A transport mode: |
peak |
Logical. If |
year |
Numeric. A year number in YYYY format. Defaults to 2019. |
geometry |
Logical. If |
showProgress |
Logical. Defaults to |
Details
The output also includes the land use and population columns returned
by read_landuse(); see its documentation or aopdata_dictionary().
Value
A data.table, or an sf object (which also inherits from
data.table) when geometry = TRUE.
Data dictionary:
| data_type | column | description | values |
| temporal | year | Year of reference | |
| transport | mode | Transport mode | walk; bicycle; public_transport; car |
| transport | peak | Peak and off-peak | 1 (peak); 0 (off-peak) |
The name of the columns with accessibility estimates are the junction of three components: 1) Type of accessibility indicator 2) Type of opportunity / population 3) Time threshold
1) Type of accessibility indicator
| Indicator | Description | Observation |
| CMA | Cumulative opportunity measure (active) | |
| CMP | Cumulative opportunity measure (passive) | |
| TMI | Travel time to closest opportunity | Value = Inf when no opportunity is reachable within the maximum travel time considered in the routing |
2) Type of opportunity / population
| Type of opportunity | Description | Observation: available in combination with |
| TT | All jobs | CMA indicator |
| TB | Jobs with primary education | CMA indicator |
| TM | Jobs with secondary education | CMA indicator |
| TA | Jobs with tertiary education | CMA indicator |
| ST | All healthcare facilities | CMA and TMI indicators |
| SB | Healthcare facilities - Low complexity | CMA and TMI indicators |
| SM | Healthcare facilities - Medium complexity | CMA and TMI indicators |
| SA | Healthcare facilities - High complexity | CMA and TMI indicators |
| ET | All public schools | CMA and TMI indicators |
| EI | Public schools - early childhood | CMA and TMI indicators |
| EF | Public schools - elementary schools | CMA and TMI indicators |
| EM | Public schools - high schools | CMA and TMI indicators |
| MT | All school enrollments | CMA indicator |
| MI | School enrollments - early childhood | CMA indicator |
| MF | School enrollments - elementary schools | CMA indicator |
| MM | School enrollments - high schools | CMA indicator |
| CT | All Social Assistance Reference Centers (CRAS) | CMA and TMI indicators |
| People | Description | Observation: available in combination with |
| PT | All population | CMP indicator |
| PH | Men | CMP indicator |
| PM | Women | CMP indicator |
| PB | White population | CMP indicator |
| PA | Asian-descendent population | CMP indicator |
| PI | Indigenous population | CMP indicator |
| PN | Black population | CMP indicator |
| P0005I | Population between 0 and 5 years old | CMP indicator |
| P0614I | Population between 6 and 14 years old | CMP indicator |
| P1518I | Population between 15 and 18 years old | CMP indicator |
| P1924I | Population between 19 and 24 years old | CMP indicator |
| P2539I | Population between 25 and 39 years old | CMP indicator |
| P4069I | Population between 40 and 69 years old | CMP indicator |
| P70I | Population with 70 years old or more | CMP indicator |
3) Time threshold (only applicable to CMA and CMP estimates)
| Time threshold | **Description ** | Observation: only applicable to |
| 15 | Opportunities accessible within 15 min. | All transport modes |
| 30 | Opportunities accessible within 30 min. | All transport modes |
| 45 | Opportunities accessible within 45 min. | Active transport modes |
| 60 | Opportunities accessible within 60 min. | All transport modes |
| 90 | Opportunities accessible within 90 min. | Public transport and car |
| 120 | Opportunities accessible within 120 min. | Public transport and car |
4) Cities available
Walking and cycling: all cities, 2017 to 2019. Car: all cities, 2019.
Public transport: bho, cam, cur, for, poa, spo (2017 to
2019); rio (2018 and 2019); goi, rec (2019).
| City name | Three-letter abbreviation |
| Belem | bel |
| Belo Horizonte | bho |
| Brasilia | bsb |
| Campinas | cam |
| Campo Grande | cgr |
| Curitiba | cur |
| Duque de Caxias | duq |
| Fortaleza | for |
| Goiania | goi |
| Guarulhos | gua |
| Maceio | mac |
| Manaus | man |
| Natal | nat |
| Porto Alegre | poa |
| Recife | rec |
| Rio de Janeiro | rio |
| Salvador | sal |
| Sao Goncalo | sgo |
| Sao Luis | slz |
| Sao Paulo | spo
|
Examples
# Read accessibility estimates of a single city
df <- read_access(
city = 'Fortaleza',
mode = 'public_transport',
year = 2019,
showProgress = FALSE
)
# Read accessibility estimates for all cities
all <- read_access(
city = 'all',
mode = 'walk',
year = 2019,
showProgress = FALSE
)
Download spatial hexagonal grid H3
Description
Results of the AOP project are spatially aggregated on a H3 spatial grid at resolution 9, with a side of 174 meters and an area of 0.10 km2. More information about H3 at https://h3geo.org/docs/core-library/restable/. See the documentation 'Details' for the data dictionary.
Usage
read_grid(city = NULL, showProgress = FALSE)
Arguments
city |
Character. A city name or three-letter abbreviation. If
|
showProgress |
Logical. If |
Value
An sf data.frame object
Data dictionary:
| Data type | column | Description |
| geographic | id_hex | Unique id of hexagonal cell |
| geographic | abbrev_muni | Abbreviation of city name (3 letters) |
| geographic | name_muni | City name |
| geographic | code_muni | 7-digit code of each city |
Cities available
| City name | Three-letter abbreviation |
| Belem | bel |
| Belo Horizonte | bho |
| Brasilia | bsb |
| Campinas | cam |
| Campo Grande | cgr |
| Curitiba | cur |
| Duque de Caxias | duq |
| Fortaleza | for |
| Goiania | goi |
| Guarulhos | gua |
| Maceio | mac |
| Manaus | man |
| Natal | nat |
| Porto Alegre | poa |
| Recife | rec |
| Rio de Janeiro | rio |
| Salvador | sal |
| Sao Goncalo | sgo |
| Sao Luis | slz |
| Sao Paulo | spo
|
Examples
# Read spatial grid of a single city
nat <- read_grid(city = 'Natal', showProgress = FALSE)
# Read spatial grid of all cities in the project
# all <- read_grid(city = 'all', showProgress = FALSE)
Download land use and population data
Description
Download data on the spatial distribution of population, jobs, schools, health care and social assistance facilities at a fine spatial resolution for the cities included in the AOP project. See the documentation 'Details' for the data dictionary. The data set reports information for each hexagon in a H3 spatial grid at resolution 9, with a side of 174 meters and an area of 0.10 km2. More information about H3 at https://h3geo.org/docs/core-library/restable/.
Usage
read_landuse(city = NULL, year = 2019, geometry = FALSE, showProgress = TRUE)
Arguments
city |
Character. A city name or three-letter abbreviation. If
|
year |
Numeric. A year number in YYYY format. Defaults to 2019. |
geometry |
Logical. If |
showProgress |
Logical. Defaults to |
Value
A data.table, or an sf object (which also inherits from
data.table) when geometry = TRUE.
Data dictionary:
| data_type | column | description | values |
| temporal | year | Year of reference | |
| geographic | id_hex | Unique id of hexagonal cell | |
| geographic | abbrev_muni | Abbreviation of city name (3 letters) | |
| geographic | name_muni | City name | |
| geographic | code_muni | 7-digit code of each city | |
| sociodemographic | P001 | Total number of residents | |
| sociodemographic | P002 | Number of white residents | |
| sociodemographic | P003 | Number of black residents | |
| sociodemographic | P004 | Number of indigenous residents | |
| sociodemographic | P005 | Number of Asian-descendant residents | |
| sociodemographic | P006 | Number of men | |
| sociodemographic | P007 | Number of women | |
| sociodemographic | P010 | Number of people between 0 and 5 years old | |
| sociodemographic | P011 | Number of people between 6 and 14 years old | |
| sociodemographic | P012 | Number of people between 15 and 18 years old | |
| sociodemographic | P013 | Number of people between 19 and 24 years old | |
| sociodemographic | P014 | Number of people between 25 and 39 years old | |
| sociodemographic | P015 | Number of people between 40 and 69 years old | |
| sociodemographic | P016 | Number of people with 70 years old or more | |
| sociodemographic | R001 | Average household income per capita | R$ (Brazilian Reais), values in 2010 |
| sociodemographic | R002 | Income quintile group | 1 (poorest), 2, 3, 4, 5 (richest) |
| sociodemographic | R003 | Income decile group | 1 (poorest), 2, 3, 4, 5, 6, 7, 8, 9, 10 (richest) |
| land use | T001 | Total number of formal jobs | |
| land use | T002 | Number of formal jobs with primary education | |
| land use | T003 | Number of formal jobs with secondary education | |
| land use | T004 | Number of formal jobs with tertiary education | |
| land use | E001 | Total number of public schools | |
| land use | E002 | Number of public schools - early childhood | |
| land use | E003 | Number of public schools - elementary schools | |
| land use | E004 | Number of public schools - high schools | |
| land use | M001 | Total number of school enrollments | |
| land use | M002 | Number of school enrollments - early childhood | |
| land use | M003 | Number of school enrollments - elementary schools | |
| land use | M004 | Number of school enrollments - high schools | |
| land use | S001 | Total number of healthcare facilities | |
| land use | S002 | Number of healthcare facilities - low complexity | |
| land use | S003 | Number of healthcare facilities - medium complexity | |
| land use | S004 | Number of healthcare facilities - high complexity | |
| land use | C001 | Total number of Social Assistance Reference Centers (CRAS) |
Cities available
| City name | Three-letter abbreviation |
| Belem | bel |
| Belo Horizonte | bho |
| Brasilia | bsb |
| Campinas | cam |
| Campo Grande | cgr |
| Curitiba | cur |
| Duque de Caxias | duq |
| Fortaleza | for |
| Goiania | goi |
| Guarulhos | gua |
| Maceio | mac |
| Manaus | man |
| Natal | nat |
| Porto Alegre | poa |
| Recife | rec |
| Rio de Janeiro | rio |
| Salvador | sal |
| Sao Goncalo | sgo |
| Sao Luis | slz |
| Sao Paulo | spo
|
Examples
# a single city: pass the city name
bho <- read_landuse(
city = 'Belo Horizonte',
year = 2019,
showProgress = FALSE
)
# ... or pass a three-letter abbreviation
bho <- read_landuse(
city = 'bho',
year = 2019,
showProgress = FALSE
)
# all cities
all <- read_landuse(city = 'all', year = 2019)
Read and validate a metadata file
Description
Read and validate a metadata file
Usage
read_metadata(path)
Arguments
path |
Path to a metadata csv file. |
Value
A data.table, or NULL if the file is missing, can't be read,
is empty or lacks the columns used by the package.
Download population and socioeconomic data
Description
Download population and socioeconomic data from the Brazilian Census at a fine spatial resolution for the cities included in the AOP project. See the documentation 'Details' for the data dictionary. The data set reports information for each hexagon in a H3 spatial grid at resolution 9, with a side of 174 meters and an area of 0.10 km2. More information about H3 at https://h3geo.org/docs/core-library/restable/.
Usage
read_population(
city = NULL,
year = 2010,
geometry = FALSE,
showProgress = TRUE
)
Arguments
city |
Character. A city name or three-letter abbreviation. If
|
year |
Numeric. Year of the census data. Only 2010 is available (the default). |
geometry |
Logical. If |
showProgress |
Logical. Defaults to |
Value
A data.table, or an sf object (which also inherits from
data.table) when geometry = TRUE.
Data dictionary:
| data_type | column | description | values |
| temporal | year | Year of reference | |
| geographic | id_hex | Unique id of hexagonal cell | |
| geographic | abbrev_muni | Abbreviation of city name (3 letters) | |
| geographic | name_muni | City name | |
| geographic | code_muni | 7-digit code of each city | |
| sociodemographic | P001 | Total number of residents | |
| sociodemographic | P002 | Number of white residents | |
| sociodemographic | P003 | Number of black residents | |
| sociodemographic | P004 | Number of indigenous residents | |
| sociodemographic | P005 | Number of Asian-descendant residents | |
| sociodemographic | P006 | Number of men | |
| sociodemographic | P007 | Number of women | |
| sociodemographic | P010 | Number of people between 0 and 5 years old | |
| sociodemographic | P011 | Number of people between 6 and 14 years old | |
| sociodemographic | P012 | Number of people between 15 and 18 years old | |
| sociodemographic | P013 | Number of people between 19 and 24 years old | |
| sociodemographic | P014 | Number of people between 25 and 39 years old | |
| sociodemographic | P015 | Number of people between 40 and 69 years old | |
| sociodemographic | P016 | Number of people with 70 years old or more | |
| sociodemographic | R001 | Average household income per capita | R$ (Brazilian Reais), values in 2010 |
| sociodemographic | R002 | Income quintile group | 1 (poorest), 2, 3, 4, 5 (richest) |
| sociodemographic | R003 | Income decile group | 1 (poorest), 2, 3, 4, 5, 6, 7, 8, 9, 10 (richest) |
Cities available
| City name | Three-letter abbreviation |
| Belem | bel |
| Belo Horizonte | bho |
| Brasilia | bsb |
| Campinas | cam |
| Campo Grande | cgr |
| Curitiba | cur |
| Duque de Caxias | duq |
| Fortaleza | for |
| Goiania | goi |
| Guarulhos | gua |
| Maceio | mac |
| Manaus | man |
| Natal | nat |
| Porto Alegre | poa |
| Recife | rec |
| Rio de Janeiro | rio |
| Salvador | sal |
| Sao Goncalo | sgo |
| Sao Luis | slz |
| Sao Paulo | spo
|
Examples
# a single city: pass the city name
bho <- read_population(
city = 'Belo Horizonte',
year = 2010,
showProgress = FALSE
)
# ... or pass a three-letter abbreviation
bho <- read_population(
city = 'bho',
year = 2010,
showProgress = FALSE
)
# all cities
all <- read_population(city = 'all', year = 2010)
Select city input
Description
Subsets the metadata table by 'city'.
Usage
select_city_input(temp_meta = temp_meta, city = NULL)
Arguments
temp_meta |
A data.frame with the url addresses of aop datasets |
city |
city input (passed from read_ function) |
Value
A data.frame object with metadata subsetted by 'city'
Select metadata
Description
Subsets the metadata table by data 'type', 'city', 'year' and 'mode'
Usage
select_metadata(t = NULL, c = NULL, y = NULL, m = NULL)
Arguments
t |
Type of data: 'access' or 'grid' (passed from |
c |
City (passed from |
y |
Year of the dataset (passed from |
m |
Transport mode (passed from |
Value
A data.frame object with metadata subsetted by data type,
'city', 'year' and 'mode'
Select mode input
Description
Subsets the metadata table by 'mode'.
Usage
select_mode_input(
temp_meta = temp_meta,
mode = NULL,
all_cities = FALSE,
year_meta = temp_meta
)
Arguments
temp_meta |
A data.frame with the url addresses of aop datasets |
mode |
Transport mode (passed by read_ function) |
all_cities |
Logical. |
year_meta |
The metadata of the selected type and year, before the city filter. Used to find the cities with this mode. |
Value
A data.frame object with metadata subsetted by 'mode'
Select year input
Description
Subsets the metadata table by 'year'.
Usage
select_year_input(temp_meta = temp_meta, year = NULL)
Arguments
temp_meta |
A data.frame with the url addresses of aop datasets |
year |
Year of the dataset (passed from read_ function) |
Value
A data.frame object with metadata subsetted by 'year'