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')
airports_priv <- flightsbr::read_airports(type = 'public')
airports_publ
# 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
<- rbindlist(list(airports_priv,airports_publ), fill = T)
airports
# plot
<- geobr::read_country()
brazil
ggplot() +
geom_sf(data=brazil, color='gray') +
geom_point(data=airports, aes(x=longitude, y=latitude), size=.5 , alpha=.4) +
theme_void()