Type: | Package |
Title: | Plotting Flight Paths on Maps |
Version: | 0.1.0 |
Maintainer: | Mingchu Xu <mxu.china@gmail.com> |
Depends: | R (≥ 3.6) |
Description: | Provides functionality to plot airplane flight paths on maps. The plotted flight paths follow the great circle of the Earth. |
License: | GPL-3 | file LICENSE |
LazyData: | TRUE |
Imports: | dplyr, geosphere, ggplot2, ggrepel, magrittr, rlang, sf, tibble |
Collate: | "data.R" "globals.R" "helpers.R" "main.R" |
URL: | https://github.com/xmc811/flightplot |
BugReports: | https://github.com/xmc811/flightplot/issues |
RoxygenNote: | 7.1.0 |
Encoding: | UTF-8 |
NeedsCompilation: | no |
Packaged: | 2020-06-26 18:21:44 UTC; mxu3 |
Author: | Mingchu Xu [aut, cre] |
Repository: | CRAN |
Date/Publication: | 2020-06-29 09:20:06 UTC |
The Information of All Aiports
Description
A dataframe with basic information of airports all over the world
Usage
airports
Format
Dataframe
- ID
Unique OpenFlights identifier for this airport.
- Name
Name of airport. May or may not contain the City name.
- City
Main city served by airport. May be spelled differently from Name.
- Country
Country or territory where airport is located. See Countries to cross-reference to ISO 3166-1 codes.
- IATA
3-letter IATA code. Null if not assigned/unknown.
- ICAO
4-letter ICAO code. Null if not assigned.
- Latitude
Decimal degrees, usually to six significant digits. Negative is South, positive is North.
- Longtitude
Decimal degrees, usually to six significant digits. Negative is West, positive is East.
- Altitude
In feet.
- Timezone
Hours offset from UTC. Fractional hours are expressed as decimals, eg. India is 5.5.
- DST
Daylight savings time. One of E (Europe), A (US/Canada), S (South America), O (Australia), Z (New Zealand), N (None) or U (Unknown).
- TZName
Timezone in "tz" (Olson) format, eg. "America/Los_Angeles".
- Type
Type of the airport. Value "airport" for air terminals, "station" for train stations, "port" for ferry terminals and "unknown" if not known. In airports.csv, only type=airport is included.
- Source
Source of this data. "OurAirports" for data sourced from OurAirports, "Legacy" for old data not matched to OurAirports (mostly DAFIF), "User" for unverified user contributions.
Source
<https://github.com/jpatokal/openflights/blob/master/data/airports.dat>
Examples
airports
Helper function to reorder the values in the input flight dataframe.
Description
Helper function to reorder the values in the input flight dataframe.
Usage
arrange_path(df)
Arguments
df |
A two-column dataframe - The start and end airports of flights. |
Value
A two-column dataframe
Examples
arrange_path(sample_trips)
Helper function to calculate the coordinate limits of map border
Description
Since the world map is huge, and flights are usually drawn in a relatively
small area, the map needs to be cropped based on the coordinates of airports
used. This function generates the coordinate limits of the cropped map.
Usage
get_map_border(v, type = c("long", "lat"), padding_ratio = 0.1)
Arguments
v |
A double numeric vector - vector of longtitudes/latitudes. |
type |
A string - "long" or "lat". It indicates whether longtitudes or latitudes are input. |
padding_ratio |
A double number - 0 to 1. The padding ratio is defined as |
Value
A two-column dataframe
Examples
get_map_border(c(-20,30,60,85), type = "lat")
get_map_border(c(-10,0,10,40), type = "long", padding_ratio = 0.2)
The main function to plot flight paths
Description
The plot_flights
function use 'ggplot2' to plot flight paths on a world map. The flight path follow the great circle of the Earth, which is computed by 'geosphere'. The function also provides extended functionalities including coloring and cropping.
Since 'ggplot2' is used, additional plotting parameters can be easily added to the result.
Usage
plot_flights(
trips,
crop = TRUE,
land_color = "#f6e8c3",
water_color = "aliceblue",
dom_color = "#3288bd",
int_color = "#d53e4f",
alpha = 0.5,
times_as_thickness = TRUE
)
Arguments
trips |
A two-column dataframe - The start and end airports of flights. The first column should be the start airports, and the second column the end airports. The airport value should be IATA airport code. The column names can be any valid names. |
crop |
A logical value or a string - Whether the map should be cropped or not and by which preset the map is cropped. If |
land_color |
A string - the color used for land. Default value is |
water_color |
A string - the color used for earth. Default value is |
dom_color |
A string - the color used for domestic flights. Default value is |
int_color |
A string - the color used for international flights. Default value is |
alpha |
A double number - 0 to 1. The transparency (alpha) of flight paths. Default value is |
times_as_thickness |
A logical value - whether the times of flights are used as aestheic mappings for the thickness of flight paths. Default value is |
Value
A plot
Examples
plot_flights(sample_trips[1:20,])
Sample Trip Dataset
Description
A two-column dataframe with start and end airports of flights. The dataframe can be readily used as input for the main plot function.
Usage
sample_trips
Format
Dataframe
- Departure
IATA code for departure airports
- Arrival
IATA code for arrival airports.
Examples
sample_trips
World Map Vector Data
Description
A simple feature dataframe generated from world land and earth shapefile.
Usage
world
Format
A simple feature dataframe.
Source
<https://www.naturalearthdata.com/downloads/50m-physical-vectors/50m-land/>
Examples
sf::st_as_sf(world)