A function that returns details of all airports within a user-specified distance of an input coordinate location. Takes as input a longitude and latitude argument.

airports_around(lat, lon, distance = 100)

Arguments

lat

Latitude in decimal degrees

lon

Longitude in decimal degrees

distance

Distance boundary for nearest airport lookup in kilometres

Value

A tibble of airports that fall within the specified range of specified location

Examples

airports_around(49.2, -123)
#> # A tibble: 24 × 17
#>    `OpenFlights ID` Name                City  IATA  ICAO  Country `Country Code`
#>               <dbl> <chr>               <chr> <chr> <chr> <chr>   <chr>         
#>  1               33 Nanaimo Airport     Nana… "YCD" CYCD  Canada  124           
#>  2               39 Chilliwack Airport  Chil… "YCW" CYCW  Canada  124           
#>  3              104 Pitt Meadows Airpo… Pitt… "\\N" CYPK  Canada  124           
#>  4              156 Vancouver Internat… Vanc… "YVR" CYVR  Canada  124           
#>  5              175 Abbotsford Airport  Abbo… "YXX" CYXX  Canada  124           
#>  6              184 Victoria Internati… Vict… "YYJ" CYYJ  Canada  124           
#>  7             3573 Whidbey Island Nav… Whid… "NUW" KNUW  United… 840           
#>  8             3777 Bellingham Interna… Bell… "BLI" KBLI  United… 840           
#>  9             4106 Victoria Harbour S… Vict… "YWH" CYWH  Canada  124           
#> 10             5500 Vancouver Harbour … Vanc… "CXH" CYHC  Canada  124           
#> # ℹ 14 more rows
#> # ℹ 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>

# Or with a user specified distance in kilometres
airports_around(49.2, -123, distance = 200)
#> # A tibble: 42 × 17
#>    `OpenFlights ID` Name                City  IATA  ICAO  Country `Country Code`
#>               <dbl> <chr>               <chr> <chr> <chr> <chr>   <chr>         
#>  1               30 Campbell River Air… Camp… "YBL" CYBL  Canada  124           
#>  2               33 Nanaimo Airport     Nana… "YCD" CYCD  Canada  124           
#>  3               39 Chilliwack Airport  Chil… "YCW" CYCW  Canada  124           
#>  4               44 Princeton Airport   Prin… "\\N" CYDC  Canada  124           
#>  5               78 Kamloops Airport    Kaml… "YKA" CYKA  Canada  124           
#>  6              104 Pitt Meadows Airpo… Pitt… "\\N" CYPK  Canada  124           
#>  7              119 Comox Airport       Comox "YQQ" CYQQ  Canada  124           
#>  8              156 Vancouver Internat… Vanc… "YVR" CYVR  Canada  124           
#>  9              175 Abbotsford Airport  Abbo… "YXX" CYXX  Canada  124           
#> 10              184 Victoria Internati… Vict… "YYJ" CYYJ  Canada  124           
#> # ℹ 32 more rows
#> # ℹ 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>