Introduction to the Airpotr Package

Dmitry Shkolnik

2019-10-09

Overview

This package uses regularly updated open source airport data to provide convenience tools for working with airport name and location data. These tools include functions to:

Data

Airport data is from the OpenFlights Airport Database made available under the Open Database License.

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.

Lookup Functions

This packages primary use-case is to facilitate working with and translating structured airport data from one format into another.

airport_lookup

The airport_lookup() function takes either an IATA code, an IACO code, or an airport name, and returns a translated value of selected output type.

If an input type is unknown or not provided, airport_lookup will attempt to guess the appropriate input type. Output type should always be specified; however.

airport_detail

The airport_detail function returns all available information for an airport given an airport name, IATA code, or ICAO code as input. The input type can be manually specified, but if nothing is provided function will attempt to guess the correct input type. If no matches are returned, similarly named objects will be returned as suggestions with a warning.

airport_location

The airport_location function returns longitude/latitude coordinate pairs for the location of an airport, using an airport name, IATA code, or ICAO code as input argument.

city_airports

The city_airports 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.

Distance Functions

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

airport_distance

The airport_distance function takes two airport IATA codes as arguments and returns the great circle distance between the two airports. Distances are returned in kilometres. Distances are calculated using the Haversine formula which assumes a spherical earth.

While the Haversine formula is reasonably accurate for most uses, due to the Earth’s ellipsoidal nature, the Haversine formula may result in errors of up to 0.3% in some areas, particularly near the poles. If distance accuracy is critical, there are more robust distance measures implemented as options in the geosphere package.

airports_near_airport

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.

The airports_near_airport function takes an airport name, IATA code, or IACO code as an input argument, and returns all other airports within a 100km radius by default. Other distance ranges can be specified by modifying the default distance = 100 parameter.

airports_around

The airports_around function takes three arguments, a latitude coordinate, a longitude coordinate and a specified distance in kilometres and lookups all airports within the specified radius around the input coordinates.

This package does not include tools for working with online geocoding or gazeteer lookups by design to keep dependencies as minimal as possible and to work without needing an internet connection. Geocoding and coordinate lookup tools are available in a number of packages including ggmap, googleway, tmap, nominatim, rmapzen, and others. In order to locate airports near a specified named location such as a city name or address, first geocode the named location and then use the resulting coordinates as an input into airports_around().