| Title: | Download Flight and Airport Data from Brazil |
|---|---|
| Description: | Download flight and airport data from Brazil’s Civil Aviation Agency (ANAC) <https://www.gov.br/anac/pt-br>. The data covers detailed information on aircraft, airports, and airport operations registered with ANAC. It also includes data on airfares, all international flights to and from Brazil, and domestic flights within the country. |
| Authors: | Rafael H. M. Pereira [aut, cre] (ORCID: <https://orcid.org/0000-0003-2125-7465>), Arthur Bazolli [ctb], Ipea - Institute for Applied Economic Research [cph, fnd] |
| Maintainer: | Rafael H. M. Pereira <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.3.0 |
| Built: | 2026-11-20 21:31:22 UTC |
| Source: | https://github.com/cran/flightsbr |
Deletes files from the flightsbr cache folder (see
get_flightsbr_cache_dir()): all cached files, or only the ones named in
file.
delete_flightsbr_cache(file = NULL, verbose = TRUE)delete_flightsbr_cache(file = NULL, verbose = TRUE)
file |
String. Names of cached files to delete, for example
|
verbose |
Logical. Whether to print a message saying what was deleted.
Defaults to |
Only files saved directly in the cache folder are deleted. Subfolders and
their content are never touched, so pointing the cache at a folder that
also holds other things (see set_flightsbr_cache_dir()) can't wipe them
out. The cache folder itself is removed if it ends up empty.
Invisibly, the path to the cache folder.
Other Cache data:
get_flightsbr_cache_dir(),
list_flightsbr_cache(),
set_flightsbr_cache_dir()
# delete one file delete_flightsbr_cache("basica2000-01.zip") # delete all cached files delete_flightsbr_cache()# delete one file delete_flightsbr_cache("basica2000-01.zip") # delete all cached files delete_flightsbr_cache()
Download flight and airport data from Brazil’s Civil Aviation Agency (ANAC) https://www.gov.br/anac/pt-br. The data includes detailed information on all aircrafts, aerodromes, airports, and airport movements registered in ANAC, and on every international flight to and from Brazil, as well as domestic flights within the country.
Please check the vignettes and data documentation on the website.
Maintainer: Rafael H. M. Pereira [email protected] (ORCID)
Authors:
Rafael H. M. Pereira [email protected] (ORCID)
Other contributors:
Arthur Bazolli [email protected] [contributor]
Ipea - Institute for Applied Economic Research [copyright holder, funder]
Useful links:
Report bugs at https://github.com/ipea/flightsbr/issues
Returns the folder used to cache data downloaded by flightsbr: the folder
set with set_flightsbr_cache_dir(), possibly in a previous R session, or
the default folder, tools::R_user_dir("flightsbr", which = "cache").
get_flightsbr_cache_dir()get_flightsbr_cache_dir()
String. The path to the cache folder. The folder may not exist yet if no data has been downloaded.
Other Cache data:
delete_flightsbr_cache(),
list_flightsbr_cache(),
set_flightsbr_cache_dir()
get_flightsbr_cache_dir()get_flightsbr_cache_dir()
Check the date of the latest airfare data available
latest_airfares_date(dom = TRUE)latest_airfares_date(dom = TRUE)
dom |
Logical. Defaults to |
A numeric date in the format yyyymm.
Other support function:
latest_flights_date()
## Not run: if (interactive()) { latest_date <- latest_airfares_date() } ## End(Not run)## Not run: if (interactive()) { latest_date <- latest_airfares_date() } ## End(Not run)
Check the date of the latest flight data available
latest_flights_date()latest_flights_date()
A numeric date in the format yyyymm.
Other support function:
latest_airfares_date()
## Not run: if (interactive()) { latest_date <- latest_flights_date() } ## End(Not run)## Not run: if (interactive()) { latest_date <- latest_flights_date() } ## End(Not run)
Lists the files saved in the flightsbr cache folder (see
get_flightsbr_cache_dir()).
list_flightsbr_cache(print_tree = FALSE)list_flightsbr_cache(print_tree = FALSE)
print_tree |
Logical. Whether to print the content of the cache folder
as a tree. Defaults to |
A character vector with the paths of the cached files (invisibly
when print_tree = TRUE). An empty vector if nothing is cached.
Other Cache data:
delete_flightsbr_cache(),
get_flightsbr_cache_dir(),
set_flightsbr_cache_dir()
list_flightsbr_cache() list_flightsbr_cache(print_tree = TRUE)list_flightsbr_cache() list_flightsbr_cache(print_tree = TRUE)
Download data of all aircraft registered in the Brazilian Aeronautical Registry (Registro Aeronáutico Brasileiro - RAB), organized by the Brazilian Civil Aviation Agency (ANAC). A description of all variables included in the data is available at https://www.gov.br/anac/pt-br/sistemas/rab.
read_aircraft(date = NULL, showProgress = TRUE, cache = TRUE)read_aircraft(date = NULL, showProgress = TRUE, cache = TRUE)
date |
Numeric. Date of the data in the format |
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read cached data downloaded
previously. Defaults to |
A "data.table" "data.frame" object. Columns of counts and
measures are numeric; codes and identifiers (e.g. flight numbers,
serial numbers, airport codes) are character, keeping leading
zeros. A column with some values that are not numbers stays
character, with a message.
Other download flight data:
read_aircrafts(),
read_flights()
## Not run: if (interactive()) { # Read aircraft data aircraft <- read_aircraft(date = 202409, showProgress = TRUE ) } ## End(Not run)## Not run: if (interactive()) { # Read aircraft data aircraft <- read_aircraft(date = 202409, showProgress = TRUE ) } ## End(Not run)
Download data on air fares of domestic and international flights in Brazil. The data is collected by Brazil’s Civil Aviation Agency (ANAC). A description of all variables included in the data for domestic airfares is available at https://www.anac.gov.br/acesso-a-informacao/dados-abertos/areas-de-atuacao/voos-e-operacoes-aereas/tarifas-aereas-domesticas/46-tarifas-aereas-domesticas. A description of all variables included in the data for international airfares is available at https://www.gov.br/anac/pt-br/assuntos/dados-e-estatisticas/microdados-de-tarifas-aereas-comercializadas.
read_airfares( date = NULL, domestic = TRUE, showProgress = TRUE, select = NULL, cache = TRUE )read_airfares( date = NULL, domestic = TRUE, showProgress = TRUE, select = NULL, cache = TRUE )
date |
Numeric. Date of the data in the format |
domestic |
Logical. Defaults to |
showProgress |
Logical. Defaults to |
select |
A vector of column names or positions to keep. The order that
the columns passed determines the order of the columns in the result.
In |
cache |
Logical. Whether the function should read cached data downloaded
previously. Defaults to |
ANAC has changed the column names of these files several times. All files
are returned with the names ANAC uses in its current files
(nr_ano_referencia, nr_mes_referencia, sg_empresa_icao,
sg_icao_origem, sg_icao_destino, nr_tarifa, nr_assentos and, for
international flights, sg_icao_retorno, cd_classe_ida,
cd_classe_volta), so files from different years can be combined.
select accepts these names as well as older names such as "TARIFA" or
"ano".
A "data.table" "data.frame" object.
## Not run: if (interactive()) { # Read air fare data af_201506 <- read_airfares(date = 201506, domestic = TRUE) af_2015 <- read_airfares(date = 2015, domestic = TRUE) } ## End(Not run)## Not run: if (interactive()) { # Read air fare data af_201506 <- read_airfares(date = 201506, domestic = TRUE) af_2015 <- read_airfares(date = 2015, domestic = TRUE) } ## End(Not run)
Download airport movements data from Brazil’s Civil Aviation Agency (ANAC). The data covers all passenger, aircraft, cargo and mail movement data from airports regulated by ANAC. Data only available from March 2019 onwards. A description of all variables included in the data is available at https://www.anac.gov.br/acesso-a-informacao/dados-abertos/areas-de-atuacao/operador-aeroportuario/dados-de-movimentacao-aeroportuaria/60-dados-de-movimentacao-aeroportuaria.
read_airport_movements(date = NULL, showProgress = TRUE, cache = TRUE)read_airport_movements(date = NULL, showProgress = TRUE, cache = TRUE)
date |
Numeric. Date of the data in the format |
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read cached data downloaded
previously. Defaults to |
A "data.table" "data.frame" object. Columns of counts and
measures are numeric; codes and identifiers (e.g. flight numbers,
serial numbers, airport codes) are character, keeping leading
zeros. A column with some values that are not numbers stays
character, with a message.
## Not run: if (interactive()) { # Read airport movement data amov202006 <- read_airport_movements(date = 202006) amov2020 <- read_airport_movements(date = 2020) } ## End(Not run)## Not run: if (interactive()) { # Read airport movement data amov202006 <- read_airport_movements(date = 202006) amov2020 <- read_airport_movements(date = 2020) } ## End(Not run)
Download data of all airports and aerodromes registered in Brazil’s Civil Aviation Agency (ANAC). Data source: https://www.gov.br/anac/pt-br/acesso-a-informacao/dados-abertos/areas-de-atuacao/aerodromos. The data dictionary for public airports can be found at https://www.anac.gov.br/acesso-a-informacao/dados-abertos/areas-de-atuacao/aerodromos/lista-de-aerodromos-publicos-v2/70-lista-de-aerodromos-publicos-v2. The data dictionary for private airports can be found at https://www.anac.gov.br/acesso-a-informacao/dados-abertos/areas-de-atuacao/aerodromos/lista-de-aerodromos-privados-v2.
read_airports(type = "all", showProgress = TRUE, cache = TRUE)read_airports(type = "all", showProgress = TRUE, cache = TRUE)
type |
String. Whether the function should download data on |
showProgress |
Logical. Defaults to |
cache |
Logical. Whether the function should read cached data downloaded
previously. Defaults to |
A "data.table" "data.frame" object.
## Not run: if (interactive()) { # Read airports data all_airports <- read_airports(type = 'all') public_airports <- read_airports(type = 'public') private_airports <- read_airports(type = 'private') } ## End(Not run)## Not run: if (interactive()) { # Read airports data all_airports <- read_airports(type = 'all') public_airports <- read_airports(type = 'public') private_airports <- read_airports(type = 'private') } ## End(Not run)
Download flight data from Brazil’s Civil Aviation Agency (ANAC). The data includes detailed information on every international flight to and from Brazil, as well as domestic flights within the country. The data include flight-level information of airports of origin and destination, flight duration, aircraft type, payload, and the number of passengers, and several other variables. A description of all variables included in the data is available at https://www.gov.br/anac/pt-br/assuntos/regulados/empresas-aereas/Instrucoes-para-a-elaboracao-e-apresentacao-das-demonstracoes-contabeis/descricao-de-variaveis.
read_flights( date = NULL, type = "basica", showProgress = TRUE, select = NULL, cache = TRUE )read_flights( date = NULL, type = "basica", showProgress = TRUE, select = NULL, cache = TRUE )
date |
Numeric. Date of the data in the format |
type |
String. Whether the data set should be of the type |
showProgress |
Logical. Defaults to |
select |
A vector of column names or positions to keep. The order that
the columns passed determines the order of the columns in the result.
In |
cache |
Logical. Whether the function should read cached data downloaded
previously. Defaults to |
A "data.table" "data.frame" object. Columns of counts and
measures are numeric; codes and identifiers (e.g. flight numbers,
serial numbers, airport codes) are character, keeping leading
zeros. A column with some values that are not numbers stays
character, with a message.
Other download flight data:
read_aircraft(),
read_aircrafts()
## Not run: if (interactive()) { # Read flights data f201506 <- read_flights(date = 201506) f2015 <- read_flights(date = 2015) } ## End(Not run)## Not run: if (interactive()) { # Read flights data f201506 <- read_flights(date = 201506) f2015 <- read_flights(date = 2015) } ## End(Not run)
flightsbr saves the files it downloads from ANAC in a cache folder, so that each file is downloaded only once, even across R sessions. This function sets which folder is used. The choice is saved and persists across R sessions.
Files already cached in the previous folder are not moved. They stay where
they are until you delete them, for example with delete_flightsbr_cache()
before changing the folder.
set_flightsbr_cache_dir(path = NULL, verbose = TRUE)set_flightsbr_cache_dir(path = NULL, verbose = TRUE)
path |
String. The path to the folder used to cache downloaded data.
If |
verbose |
Logical. Whether to print a message with the cache folder.
Defaults to |
Invisibly, the path to the cache folder.
Other Cache data:
delete_flightsbr_cache(),
get_flightsbr_cache_dir(),
list_flightsbr_cache()
# use a custom folder set_flightsbr_cache_dir(tempdir()) # go back to the default folder set_flightsbr_cache_dir(NULL)# use a custom folder set_flightsbr_cache_dir(tempdir()) # go back to the default folder set_flightsbr_cache_dir(NULL)