This function takes a city normal city name as an input argument and returns all airports associated with that city. Airports are typically associated with their local metropolitan area but some exceptions may be present in the data. If there are no matching results in the data for the city argument, a list of closely named alternatives will be suggested with a warning.

city_airports(city, country)

Arguments

city

A city name. If no exact match will attempt to prompt user with suggested alternatives

country

(Optional) A country name or ISO country code in either numeric, alpha-2, or alpha 3 format. Case insensitive.

Value

A Nx17 tibble with airport details where n is the number of airports serving that city

Examples

city_airports("Vancouver")
#> # A tibble: 5 × 17
#>   `OpenFlights ID` Name                 City  IATA  ICAO  Country `Country Code`
#>              <dbl> <chr>                <chr> <chr> <chr> <chr>   <chr>         
#> 1              156 Vancouver Internati… Vanc… "YVR" CYVR  Canada  124           
#> 2             4107 Coal Harbour Seapla… Vanc… "\\N" CAQ3  Canada  124           
#> 3             5500 Vancouver Harbour W… Vanc… "CXH" CYHC  Canada  124           
#> 4            12090 Vancouver Internati… Vanc… "\\N" CAM9  Canada  124           
#> 5            13022 Harbour (Public) He… Vanc… "\\N" CBC7  Canada  124           
#> # ℹ 10 more variables: `Country Code (Alpha-2)` <chr>,
#> #   `Country Code (Alpha-3)` <chr>, Latitude <dbl>, Longitude <dbl>,
#> #   Altitude <dbl>, UTC <chr>, DST <chr>, Timezone <chr>, Type <chr>,
#> #   Source <chr>
city_airports("London")
#> Warning: Input city matches cities in multiple countries. Do you want to specify a country argument? See documentation ?city_airports for details.
#> # A tibble: 9 × 17
#>   `OpenFlights ID` Name                 City  IATA  ICAO  Country `Country Code`
#>              <dbl> <chr>                <chr> <chr> <chr> <chr>   <chr>         
#> 1              174 London Airport       Lond… "YXU" CYXU  Canada  124           
#> 2              492 London Luton Airport Lond… "LTN" EGGW  United… 826           
#> 3              502 London Gatwick Airp… Lond… "LGW" EGKK  United… 826           
#> 4              503 London City Airport  Lond… "LCY" EGLC  United… 826           
#> 5              507 London Heathrow Air… Lond… "LHR" EGLL  United… 826           
#> 6              548 London Stansted Air… Lond… "STN" EGSS  United… 826           
#> 7             7722 London Heliport      Lond… "\\N" EGLW  United… 826           
#> 8             8410 London-Corbin Airpo… Lond… "LOZ" KLOZ  United… 840           
#> 9            10169 Madison County Airp… Lond… "\\N" KUYF  United… 840           
#> # ℹ 10 more variables: `Country Code (Alpha-2)` <chr>,
#> #   `Country Code (Alpha-3)` <chr>, Latitude <dbl>, Longitude <dbl>,
#> #   Altitude <dbl>, UTC <chr>, DST <chr>, Timezone <chr>, Type <chr>,
#> #   Source <chr>
city_airports("London","Canada")
#> # A tibble: 1 × 17
#>   `OpenFlights ID` Name           City   IATA  ICAO  Country `Country Code`
#>              <dbl> <chr>          <chr>  <chr> <chr> <chr>   <chr>         
#> 1              174 London Airport London YXU   CYXU  Canada  124           
#> # ℹ 10 more variables: `Country Code (Alpha-2)` <chr>,
#> #   `Country Code (Alpha-3)` <chr>, Latitude <dbl>, Longitude <dbl>,
#> #   Altitude <dbl>, UTC <chr>, DST <chr>, Timezone <chr>, Type <chr>,
#> #   Source <chr>
city_airports("London","CA")
#> # A tibble: 1 × 17
#>   `OpenFlights ID` Name           City   IATA  ICAO  Country `Country Code`
#>              <dbl> <chr>          <chr>  <chr> <chr> <chr>   <chr>         
#> 1              174 London Airport London YXU   CYXU  Canada  124           
#> # ℹ 10 more variables: `Country Code (Alpha-2)` <chr>,
#> #   `Country Code (Alpha-3)` <chr>, Latitude <dbl>, Longitude <dbl>,
#> #   Altitude <dbl>, UTC <chr>, DST <chr>, Timezone <chr>, Type <chr>,
#> #   Source <chr>
city_airports("London","CAN")
#> # A tibble: 1 × 17
#>   `OpenFlights ID` Name           City   IATA  ICAO  Country `Country Code`
#>              <dbl> <chr>          <chr>  <chr> <chr> <chr>   <chr>         
#> 1              174 London Airport London YXU   CYXU  Canada  124           
#> # ℹ 10 more variables: `Country Code (Alpha-2)` <chr>,
#> #   `Country Code (Alpha-3)` <chr>, Latitude <dbl>, Longitude <dbl>,
#> #   Altitude <dbl>, UTC <chr>, DST <chr>, Timezone <chr>, Type <chr>,
#> #   Source <chr>
city_airports("London","124")
#> # A tibble: 1 × 17
#>   `OpenFlights ID` Name           City   IATA  ICAO  Country `Country Code`
#>              <dbl> <chr>          <chr>  <chr> <chr> <chr>   <chr>         
#> 1              174 London Airport London YXU   CYXU  Canada  124           
#> # ℹ 10 more variables: `Country Code (Alpha-2)` <chr>,
#> #   `Country Code (Alpha-3)` <chr>, Latitude <dbl>, Longitude <dbl>,
#> #   Altitude <dbl>, UTC <chr>, DST <chr>, Timezone <chr>, Type <chr>,
#> #   Source <chr>