Type: | Package |
Title: | Download Flight and Airport Data from Brazil |
Version: | 1.1.1 |
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. |
License: | MIT + file LICENSE |
URL: | https://github.com/ipeaGIT/flightsbr |
BugReports: | https://github.com/ipeaGIT/flightsbr/issues |
Depends: | R (≥ 2.10) |
Imports: | archive, curl (≥ 5.0.0), data.table (≥ 1.14.0), fs, lifecycle, parzer, pbapply, janitor, rvest |
Suggests: | dplyr, ggplot2 (≥ 3.3.1), rmarkdown (≥ 2.6), knitr, testthat |
VignetteBuilder: | knitr |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-07-24 18:08:09 UTC; rafap |
Author: | Rafael H. M. Pereira
|
Maintainer: | Rafael H. M. Pereira <rafa.pereira.br@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-07-24 23:50:16 UTC |
flightsbr: 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 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.
Usage
Please check the vignettes and data documentation on the website.
Author(s)
Maintainer: Rafael H. M. Pereira rafa.pereira.br@gmail.com (ORCID)
Other contributors:
Ipea - Institute for Applied Economic Research [copyright holder, funder]
See Also
Useful links:
Convert altitude column to numeric
Description
Convert altitude column to numeric
Usage
altitude_to_numeric(df)
Arguments
df |
A data.frame internal to the |
Value
A "data.table" "data.frame"
object
Check whether date input is acceptable
Description
Check whether date input is acceptable
Usage
check_date(date, all_dates)
Arguments
date |
Numeric. Either a 6-digit date in the format |
all_dates |
Numeric vector created with the get_all_dates_available() function. |
Value
Check messages.
Examples
## Not run: if (interactive()) {
# get all dates available
all_dates <- get_all_dates_available()
# check dates
a <- check_date(200011, all_dates)
}
## End(Not run)
Check whether the format of the date input is acceptable
Description
Check whether the format of the date input is acceptable
Usage
check_input_date_format(date = parent.frame()$date)
Arguments
date |
Vector. Either a 6-digit date in the format |
Value
Check messages.
Examples
## Not run: if (interactive()) {
# get all dates available
all_dates <- get_all_dates_available()
# check dates
a <- check_date(200011, all_dates)
}
## End(Not run)
Download and read ANAC aircraft data
Description
Download and read ANAC aircraft data
Usage
download_aircraft_data(
file_url = parent.frame()$file_url,
showProgress = parent.frame()$showProgress,
cache = parent.frame()$cache
)
Arguments
file_url |
String. A url passed from |
showProgress |
Logical, passed from |
cache |
Logical, passed from |
Value
A "data.table" "data.frame"
object
Examples
## Not run: if (interactive()) {
# Generate url
file_url <- get_airfares_url(dom = TRUE, year=2002, month=11)
# download data
a <- download_airfares_data(file_url=file_url, showProgress=TRUE, select=NULL)
}
## End(Not run)
Download and read ANAC air fares data
Description
Download and read ANAC air fares data
Usage
download_airfares_data(
file_urls = parent.frame()$file_urls,
showProgress = parent.frame()$showProgress,
select = parent.frame()$select,
cache = parent.frame()$cache
)
Arguments
file_urls |
String. A url passed from |
showProgress |
Logical. Defaults to |
select |
A vector of column names or positions to keep. The rest of the columns are not read. The order that the columns passed determines the order of the columns in the result. |
cache |
Logical. Whether the function should read cached data downloaded
previously. Defaults to |
Value
A "data.table" "data.frame"
object
Examples
## Not run: if (interactive()) {
# Generate url
file_url <- get_airfares_url(dom = TRUE, date=200211)
# download data
a <- download_airfares_data(file_urls=file_url, showProgress=TRUE, select=NULL)
}
## End(Not run)
Download and read ANAC airport movement data
Description
Download and read ANAC airport movement data
Usage
download_airport_movement_data(
file_url = parent.frame()$file_url,
showProgress = parent.frame()$showProgress,
cache = parent.frame()$cache
)
Arguments
file_url |
String. A url passed from |
showProgress |
Logical, passed from |
cache |
Logical, passed from |
Value
A "data.table" "data.frame"
object
Examples
## Not run: if (interactive()) {
# Generate url
file_url <- get_airport_movements_url(year=2020, month=11)
# download data
a <- download_airport_movement_data(file_url=file_url, showProgress=TRUE)
}
## End(Not run)
Download and read ANAC flight data
Description
Download and read ANAC flight data
Usage
download_flights_data(
file_url = parent.frame()$file_url,
showProgress = parent.frame()$showProgress,
select = parent.frame()$select,
cache = parent.frame()$cache
)
Arguments
file_url |
String. A url passed from |
showProgress |
Logical, passed from |
select |
A vector of column names or numbers to keep, passed from |
cache |
Logical, passed from |
Value
A "data.table" "data.frame"
object
Examples
## Not run: if (interactive()) {
# Generate url
file_url <- get_flights_url(type='basica', year=2000, month=11)
# download data
a <- download_flights_data(file_url=file_url, showProgress=TRUE, select=NULL)
}
## End(Not run)
Download file from url
Description
Download file from url
Usage
download_flightsbr_file(
file_url = parent.frame()$file_url,
showProgress = parent.frame()$showProgress,
dest_file = temp_local_file,
cache = cache
)
Arguments
file_url |
String. A url passed from |
showProgress |
Logical, passed from |
dest_file |
String, passed from |
cache |
Logical, passed from |
Value
Silently saves downloaded file to temp dir.
Examples
## Not run: if (interactive()) {
# Generate url
file_url <- get_flights_url(type='basica', date=200011)
# download data
download_flightsbr_file(file_url=file_url,
showProgress=TRUE,
dest_file = tempfile(fileext = ".zip")
)
}
## End(Not run)
Generate all months with yyyymm
format for a given year
Description
Generate all months with yyyymm
format for a given year
Usage
generate_all_months(date)
Arguments
date |
Numeric. 4-digit date in the format |
Value
Vector or strings.
Examples
## Not run: if (interactive()) {
# Generate all months in 2000
a <- check_date(2000)
b <- check_date(c(2000, 2005))
}
## End(Not run)
Retrieve all dates available for aircraft data from ANAC website
Description
Retrieve all dates available for aircraft data from ANAC website
Usage
get_aircraft_dates_available()
Value
Numeric vector.
Examples
## Not run: if (interactive()) {
# check dates
a <- get_aircraft_dates_available()
}
## End(Not run)
Put together the url of aircraft data files
Description
Put together the url of aircraft data files
Usage
get_aircraft_url(date = parent.frame()$date)
Arguments
date |
Numeric. Either a 6-digit date in the format |
Value
A url string.
Examples
## Not run: if (interactive()) {
# Generate url
a <- get_flights_url(year=2000, month=11)
}
## End(Not run)
Retrieve all dates available for airfares data from ANAC website
Description
Retrieve all dates available for airfares data from ANAC website
Usage
get_airfares_dates_available(dom)
Arguments
dom |
Logical. Defaults to |
Value
Numeric vector.
Examples
## Not run: if (interactive()) {
# check dates
a <- get_airfares_dates_available(domestic = TRUE)
}
## End(Not run)
Put together the url of airfare data files
Description
Put together the url of airfare data files
Usage
get_airfares_url(dom, date = parent.frame()$date)
Arguments
dom |
Logical. Defaults to |
date |
Numeric. Date of the data in the format |
Value
A url string.
Examples
## Not run: if (interactive()) {
# Generate url
a <- get_airfares_url(year=2002, month=11)
}
## End(Not run)
Retrieve all dates available for airport movements data
Description
Retrieve from ANAC website all dates available for airport movements data.
Usage
get_airport_movement_dates_available()
Value
Numeric vector.
Examples
## Not run: if (interactive()) {
# check dates
a <- get_airport_movement_dates_available()
}
## End(Not run)
Put together the url of airport movement data files
Description
Put together the url of airport movement data files
Usage
get_airport_movements_url(date = parent.frame()$date)
Arguments
date |
Numeric. Date of the data in the format |
Value
A url string.
Examples
## Not run: if (interactive()) {
# Generate url
a <- get_airport_movements_url(year=2000, month=11)
}
## End(Not run)
Retrieve all dates available for flights data from ANAC website
Description
Retrieve all dates available for flights data from ANAC website
Usage
get_flight_dates_available()
Value
Numeric vector.
Examples
## Not run: if (interactive()) {
# check dates
a <- get_flight_dates_available()
}
## End(Not run)
Put together the url of flight data files
Description
Put together the url of flight data files
Usage
get_flights_url(type, date)
Arguments
type |
String. Whether the data set should be of the type |
date |
Numeric. Date of the data in the format |
Value
A url string.
Examples
## Not run: if (interactive()) {
# Generate urls
a <- get_flights_url(type='basica', year=2000, month=11)
}
## End(Not run)
Check the date of the latest airfare data available
Description
Check the date of the latest airfare data available
Usage
latest_airfares_date(dom = TRUE)
Arguments
dom |
Logical. Defaults to |
Value
A numeric date in the format yyyymm
.
See Also
Other support function:
latest_flights_date()
Examples
## Not run: if (interactive()) {
latest_date <- latest_airfares_date()
}
## End(Not run)
Check the date of the latest flight data available
Description
Check the date of the latest flight data available
Usage
latest_flights_date()
Value
A numeric date in the format yyyymm
.
See Also
Other support function:
latest_airfares_date()
Examples
## Not run: if (interactive()) {
latest_date <- latest_flights_date()
}
## End(Not run)
Convert latitude and longitude columns to numeric
Description
Convert latitude and longitude columns to numeric
Usage
latlon_to_numeric(df)
Arguments
df |
A data.frame internal to the |
Value
A "data.table" "data.frame"
object
Download aircraft data from Brazil
Description
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.
Usage
read_aircraft(date = NULL, showProgress = TRUE, cache = TRUE)
Arguments
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 |
Value
A "data.table" "data.frame"
object. All columns are returned with
class
of type "character"
.
See Also
Other download flight data:
read_aircrafts()
,
read_flights()
Examples
## Not run: if (interactive()) {
# Read aircraft data
aircraft <- read_aircraft(date = 202001,
showProgress = TRUE)
}
## End(Not run)
Download aircrafts data from Brazil
Description
This function was deprecated in favor of read_aircraft()
simply to
fix a typo in the function name.
Usage
read_aircrafts(date = 202001, showProgress = TRUE, cache = TRUE)
Arguments
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 |
Value
A "data.table" "data.frame"
object. All columns are returned with
class
of type "character"
.
See Also
Other download flight data:
read_aircraft()
,
read_flights()
Examples
## Not run: if (interactive()) {
# Read aircraft data
aircraft <- read_aircraft(date = 202001,
showProgress = TRUE)
}
## End(Not run)
Download data on airfares flights in Brazil
Description
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.
Usage
read_airfares(
date = NULL,
domestic = TRUE,
showProgress = TRUE,
select = NULL,
cache = TRUE
)
Arguments
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 rest of the columns are not read. The order that the columns passed determines the order of the columns in the result. |
cache |
Logical. Whether the function should read cached data downloaded
previously. Defaults to |
Value
A "data.table" "data.frame"
object. All columns are returned with
class
of type "character"
.
Examples
## 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 movement data from Brazil
Description
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 Jan 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.
Usage
read_airport_movements(date = NULL, showProgress = TRUE, cache = TRUE)
Arguments
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 |
Value
A "data.table" "data.frame"
object. All columns are returned with
class
of type "character"
.
Examples
## Not run: if (interactive()) {
# Read airport movement data
amov202006 <- read_airport_movements(date = 202006)
amov2020 <- read_airport_movements(date = 2020)
}
## End(Not run)
Download airports data from Brazil
Description
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.
Usage
read_airports(type = "all", showProgress = TRUE, cache = TRUE)
Arguments
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 |
Value
A "data.table" "data.frame"
object.
Examples
## 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
Description
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.
Usage
read_flights(
date = NULL,
type = "basica",
showProgress = TRUE,
select = NULL,
cache = TRUE
)
Arguments
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 rest of the columns are not read. The order that the columns passed determines the order of the columns in the result. |
cache |
Logical. Whether the function should read cached data downloaded
previously. Defaults to |
Value
A "data.table" "data.frame"
object. All columns are returned with
class
of type "character"
.
See Also
Other download flight data:
read_aircraft()
,
read_aircrafts()
Examples
## Not run: if (interactive()) {
# Read flights data
f201506 <- read_flights(date = 201506)
f2015 <- read_flights(date = 2015)
}
## End(Not run)