Package 'flightplot'

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

Help Index


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
padding / (maximum - minimum)

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 FALSE, the whole world map is plotted; if TRUE, the map will be cropped based on the airport coordinates. It also accepts certain strings as presets:
"NA": North America.
"48States": The contiguous United States.
The default value is TRUE.

land_color

A string - the color used for land. Default value is "#f6e8c3".

water_color

A string - the color used for earth. Default value is "aliceblue".

dom_color

A string - the color used for domestic flights. Default value is "#3288bd".

int_color

A string - the color used for international flights. Default value is "#d53e4f".

alpha

A double number - 0 to 1. The transparency (alpha) of flight paths. Default value is 0.5.

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 TRUE.

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)