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
<- flightsbr::read_airports(type = 'private', showProgress = FALSE)
airports_priv #> Warning in if (class(dt_private) == "try-error") {: the condition has length > 1
#> and only the first element will be used
<- flightsbr::read_airports(type = 'public', showProgress = FALSE)
airports_publ #> 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
<- c('ciad','nome', 'longitude', 'latitude')
cols_to_keep <- select(airports_publ, cols_to_keep)
airports_publ <- select(airports_priv, cols_to_keep)
airports_priv
# rbind all public and private airports
<- data.table::rbindlist(list(airports_priv,airports_publ), fill = T)
airports
# 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()