The goal of footprint is to calculate carbon footprints from air travel based on IATA airport codes or latitude and longitude.
You can install the development version from GitHub with:
# install.packages("remotes") remotes::install_github("acircleda/footprint")
footprint uses the the Haversine great-circle distance formula
to calculate distance between airports or distance between latitude and
longitude pairs. This distance is then used to derive a carbon footprint
estimate, which is based on conversion factors from the Department for
Environment, Food & Rural Affairs (UK) 2019 Greenhouse Gas Conversion
Factors for Business Travel (air):
You can use pairs of three-letter IATA airport codes to calculate
distance. This function uses the
airportr package, which contains
the data and does the work of getting the distance between airports.
airportr package offers a number of useful functions for
looking up airports by city or name and getting the IATA airport codes.
The example below calculates a simple footprint estimation for an economy flight from Los Angeles International (LAX) to Heathrow (LHR). The estimate will be in CO2e (carbon dioxide equivalent, including radiative forcing). The output is always in kilograms.
airport_footprint("LAX", "LHR", "Economy", "co2e") #>  1312.696
If there is a layover in Chicago, you could calculate each leg of the trip as follows:
airport_footprint("LAX", "ORD", "Economy", "co2e") + airport_footprint("ORD", "LHR", "Economy", "co2e") #>  1387.167
We can calculate the footprint for multiple itineraries at the same time
and add to an existing data frame using
mutate. Here is some example
library(tibble) #> Warning: package 'tibble' was built under R version 4.0.3 travel_data <- tibble( name = c("Mike", "Will", "Elle"), from = c("LAX", "LGA", "TYS"), to = c("PUS", "LHR", "TPA") )
Here is how you can take the
to data and calculate
emissions for each trip. The following function calculates an estimate
for CO2 (carbon dioxide with radiative forcing).
If you have a list of cities, it might be easier to calculate emissions
based on longitude and latitude rather than trying to locate the
airports used. For example, one could take city and state data and join
that with data from
maps::us.cities to quickly get latitude and
longitude. They can then use the
latlong_footprint() function to
easily calculate emissions based on either a single itinerary or
The following example calculates the footprint of a flight from Los
Angeles (34.052235, -118.243683) to Busan, South Korea (35.179554,
129.075638). It assumes an average passenger (no
is included) and its output will be in kilograms of CO2e (the
latlong_footprint(34.052235, -118.243683, 35.179554, 129.075638) #>  1881.589
You can use
mutate to calculate emissions based on a dataframe of
latitude and longitude pairs.
Here is some example data:
travel_data2 <- tribble(~name, ~departure_lat, ~departure_long, ~arrival_lat, ~arrival_long, # Los Angeles -> Busan "Mike", 34.052235, -118.243683, 35.179554, 129.075638, # New York -> London "Will", 40.712776, -74.005974, 51.52, -0.10)
And here is code to apply it to a dataframe:
travel_data2 %>% rowwise() %>% mutate(emissions = latlong_footprint(departure_lat, departure_long, arrival_lat, arrival_long))