MyNixOS website logo
Description

Convenience Tools for Working with Airport Data.

Retrieves open source airport data and provides tools to look up information, translate names into codes and vice-verse, as well as some basic calculation functions for measuring distances. Data is licensed under the Open Database License.

airportr

Travis-CI Build Status CRAN_Status_Badge CRAN_Downloads_Badge

This package uses open source airport data to provide tools to look up information, translate names and codes into other formats, as well as some basic calculation functions for measuring distances.

Installation

install.packages("airportr")
library(airportr)

Alternatively, the dev version can be installed from Github using devtools.

# install.packages("devtools")
devtools::install_github("dshkol/airportr")
library(airportr)

Example Usage: Lookup functions

This package is primarily to facilitate working with and translating structured airport data from one format into another.

# Return an airport name given an IATA code
airport_lookup("YVR", input_type = "IATA", output_type = "name")
[1] "Vancouver International Airport"

# Return an airport IATA code given an airport name
airport_lookup("Vancouver International Airport", input_type = "name", output_type ="IATA")
[1] "YVR"

# If input type is not specified will try to guess
airport_lookup("YVR", output_type = "city")
[1] "Vancouver"

# Return all available details for an aiport given an airport name, IATA code, or ICAO code
airport_detail("YVR")
# A tibble: 1 x 14
  `OpenFlights ID` Name      City  Country IATA  ICAO  Latitude Longitude Altitude   UTC DST  
             <int> <chr>     <chr> <chr>   <chr> <chr>    <dbl>     <dbl>    <int> <dbl> <chr>
1              156 Vancouve… Vanc… Canada  YVR   CYVR      49.2     -123.       14    -8 A    
# ... with 3 more variables: Timezone <chr>, Type <chr>, Source <chr>

airport_detail("CYVR")
# A tibble: 1 x 14
  `OpenFlights ID` Name      City  Country IATA  ICAO  Latitude Longitude Altitude   UTC DST  
             <int> <chr>     <chr> <chr>   <chr> <chr>    <dbl>     <dbl>    <int> <dbl> <chr>
1              156 Vancouve… Vanc… Canada  YVR   CYVR      49.2     -123.       14    -8 A    
# ... with 3 more variables: Timezone <chr>, Type <chr>, Source <chr>

# Return location of an airport given an ICAO code
airport_location("CYVR", input_type = "ICAO")
# A tibble: 1 x 2
  Latitude Longitude
     <dbl>     <dbl>
1     49.2     -123.

# Display all airports serving a given city
city_airports("Vancouver")
# A tibble: 3 x 14
  `OpenFlights ID` Name      City  Country IATA  ICAO  Latitude Longitude Altitude   UTC DST  
             <int> <chr>     <chr> <chr>   <chr> <chr>    <dbl>     <dbl>    <int> <dbl> <chr>
1              156 Vancouve… Vanc… Canada  YVR   CYVR      49.2     -123.       14    -8 A    
2             4107 Coal Har… Vanc… Canada  "\\N" CAQ3      50.6     -128.        0    -8 A    
3             5500 Vancouve… Vanc… Canada  CXH   CYHC      49.3     -123.        0    -8 A    
# ... with 3 more variables: Timezone <chr>, Type <chr>, Source <chr>

Example Usage: Distance functions

This package also includes some convenience functions for working with distances between airports.

# Calculate distance between two airports in km
airport_distance("YVR","LHR")
[1] 7580.963

Another common airport-related task is to locate airports in the vicinity of a city or specified location. This is easy to implement with the airports_near_airport() and airports_around() functions:

#' airports_near_airport("YEG")
# A tibble: 3 x 14
  `OpenFlights ID` Name            City      Country IATA  ICAO  Latitude Longitude Altitude   UTC DST   Timezone   Type  Source 
             <int> <chr>           <chr>     <chr>   <chr> <chr>    <dbl>     <dbl>    <int> <dbl> <chr> <chr>      <chr> <chr>  
1               49 Edmonton Inter… Edmonton  Canada  YEG   CYEG      53.3     -114.     2373    -7 A     America/E… airp… OurAir…
2              131 Rocky Mountain… Rocky Mo… Canada  YRM   CYRM      52.4     -115.     3244    -7 A     America/E… airp… OurAir…
3              165 Edmonton City … Edmonton  Canada  YXD   CYXD      53.6     -114.     2202    -7 A     America/E… airp… OurAir…

#' airports_around(49.2,-123, distance = 20)
# A tibble: 3 x 14
  `OpenFlights ID` Name            City     Country IATA  ICAO  Latitude Longitude Altitude   UTC DST   Timezone    Type  Source 
             <int> <chr>           <chr>    <chr>   <chr> <chr>    <dbl>     <dbl>    <int> <dbl> <chr> <chr>       <chr> <chr>  
1              156 Vancouver Inte… Vancouv… Canada  YVR   CYVR      49.2     -123.       14    -8 A     America/Va… airp… OurAir…
2             5500 Vancouver Harb… Vancouv… Canada  CXH   CYHC      49.3     -123.        0    -8 A     America/Va… airp… OurAir…
3             7273 Boundary Bay A… Boundar… Canada  YDT   CZBB      49.1     -123.        6    -8 A     America/Va… airp… OurAir…

Data and License

Software code is licensed under the MIT license. Airport data is from the OpenFlights Airport Database made available under the Open Database License. A local copy of the license exists in the inst/extdata directory.

Disclaimer on the data from OpenFlights:

This data is not suitable for navigation. OpenFlights does not assume any responsibility whatsoever for its accuracy, and consequently assumes no liability whatsoever for results obtained or loss or damage incurred as a result of application of the data. OpenFlights expressly disclaims all warranties, expressed or implied, including but not limited to implied warranties of merchantability and fitness for any particular purpose.

To-do

  • [x] Build lookup functions with meaningful messages
  • [x] Debug lookup functions
  • [x] Add generic input for functions that can handle different types of inputs
  • [x] Add distance calculation functions
  • [x] Add nearest neighbour search and geographic lookup functions
  • [x] Submit to CRAN

Suggestions for additional functionality are welcome.

Metadata

Version

0.1.3

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows