Airport data

The airport data in the flightsbr package is downloaded from Brazil’s Civil Aviation Agency (ANAC).

[…]

Now we can load some libraries we’ll use in this vignette:

library(flightsbr)
library(dplyr)
library(data.table)
#> Warning: package 'data.table' was built under R version 4.1.2
library(ggplot2)
# library(geobr)

Download data of all airports:

# download data
airports_priv <- flightsbr::read_airports(type = 'private', showProgress = FALSE)
#> Warning in if (class(dt_private) == "try-error") {: the condition has length > 1
#> and only the first element will be used
airports_publ <- flightsbr::read_airports(type = 'public', showProgress = FALSE)
#> Warning in if (class(dt_public) == "try-error") {: the condition has length > 1
#> and only the first element will be used

# change col names to lower case
names(airports_priv) <- tolower(names(airports_priv))
names(airports_publ) <- tolower(names(airports_publ))

# select columns
cols_to_keep <- c('ciad','nome', 'longitude', 'latitude')
airports_publ <- select(airports_publ, cols_to_keep)
airports_priv <- select(airports_priv, cols_to_keep)

# rbind all public and private airports
airports <- data.table::rbindlist(list(airports_priv,airports_publ), fill = T)


# plot
# brazil <- geobr::read_country()

ggplot() +
  # geom_sf(data=brazil, color='gray') +
  geom_point(data=airports, aes(x=longitude, y=latitude), size=.5 , alpha=.4) +
  theme_void()