Title: | Plotting Flight Paths on Maps |
---|---|
Description: | Provides functionality to plot airplane flight paths on maps. The plotted flight paths follow the great circle of the Earth. |
Authors: | Mingchu Xu [aut, cre] |
Maintainer: | Mingchu Xu <[email protected]> |
License: | GPL-3 | file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-21 03:04:54 UTC |
Source: | https://github.com/xmc811/flightplot |
A dataframe with basic information of airports all over the world
airports
airports
Dataframe
Unique OpenFlights identifier for this airport.
Name of airport. May or may not contain the City name.
Main city served by airport. May be spelled differently from Name.
Country or territory where airport is located. See Countries to cross-reference to ISO 3166-1 codes.
3-letter IATA code. Null if not assigned/unknown.
4-letter ICAO code. Null if not assigned.
Decimal degrees, usually to six significant digits. Negative is South, positive is North.
Decimal degrees, usually to six significant digits. Negative is West, positive is East.
In feet.
Hours offset from UTC. Fractional hours are expressed as decimals, eg. India is 5.5.
Daylight savings time. One of E (Europe), A (US/Canada), S (South America), O (Australia), Z (New Zealand), N (None) or U (Unknown).
Timezone in "tz" (Olson) format, eg. "America/Los_Angeles".
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 of this data. "OurAirports" for data sourced from OurAirports, "Legacy" for old data not matched to OurAirports (mostly DAFIF), "User" for unverified user contributions.
<https://github.com/jpatokal/openflights/blob/master/data/airports.dat>
airports
airports
Helper function to reorder the values in the input flight dataframe.
arrange_path(df)
arrange_path(df)
df |
A two-column dataframe - The start and end airports of flights. |
A two-column dataframe
arrange_path(sample_trips)
arrange_path(sample_trips)
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.
get_map_border(v, type = c("long", "lat"), padding_ratio = 0.1)
get_map_border(v, type = c("long", "lat"), padding_ratio = 0.1)
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 |
A two-column dataframe
get_map_border(c(-20,30,60,85), type = "lat") get_map_border(c(-10,0,10,40), type = "long", padding_ratio = 0.2)
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 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.
plot_flights( trips, crop = TRUE, land_color = "#f6e8c3", water_color = "aliceblue", dom_color = "#3288bd", int_color = "#d53e4f", alpha = 0.5, times_as_thickness = TRUE )
plot_flights( trips, crop = TRUE, land_color = "#f6e8c3", water_color = "aliceblue", dom_color = "#3288bd", int_color = "#d53e4f", alpha = 0.5, times_as_thickness = TRUE )
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 |
A plot
plot_flights(sample_trips[1:20,])
plot_flights(sample_trips[1:20,])
A two-column dataframe with start and end airports of flights. The dataframe can be readily used as input for the main plot function.
sample_trips
sample_trips
Dataframe
IATA code for departure airports
IATA code for arrival airports.
sample_trips
sample_trips
A simple feature dataframe generated from world land and earth shapefile.
world
world
A simple feature dataframe.
<https://www.naturalearthdata.com/downloads/50m-physical-vectors/50m-land/>
sf::st_as_sf(world)
sf::st_as_sf(world)