Air Travel Emissions Calculator in R

Note: this is now a package! Please visit the link to install and see updated code. It follows the same methodology as below but includes functionality to calculate footprint by latitude and longitude as well as airport codes

I am hoping to soon be working with a data set of travel data for which I will need to calculate carbon emissions of flights. There are a number of online calculators, but none that I know of that could be pulled into R to call as a function and or be used to process data.

What’s in an Emissions Calculator?

So, I decided to write my own function to do so. The first thing I needed to understand was how carbon emissions for air travel are calculated. Dr. Christian Jardine authored a report in 2009 that detailed a number of different carbon emissions calculators. Nearly all are approximations that cannot account for the specifics of individual trips. However, some are better than others. The best carbon emissions calculators use information available on airplane size, fuel burn, freight weight, passenger capacity, and a number of other factors. Some of that data is proprietary, as is one of the best calculators offered by Sabre Holdings. This is one of the best because Sabre produces a reservation system used by airlines and can access the specific data needed for the most accurate emissions calculations. Other calculators, such as the ICAO calculator, is public ally available as a web interface for free, but to access the data that underlies the calculations (e.g. the Traffic by Flight Stage database) costs a lot of money. Some models are extremely simple, such as the model offered by the World Resources Institute, which basically uses a flat emissions factor of 0.18 kgCO2/km. This is a crude statistic that cannot account for a number of factors related to airplane emissions.

Luckily, I was able to find the UK’s Department for Environment, Food and Rural Affairs (DEFRA). They have updated data that is freely available and takes into consideration some of the important factors above, and include radiative forcing in their load factors. This is important to include because airplanes inject a number of greenhouse gases directly into the atmosphere and thus their emission act differently than that of cars or electricity generation.

This seems to be the best source of loadings to use for an R-based emissions calculator. The downside is that it uses the terminology domestic, short-haul, long-haul, and *international without clearly defining what they mean in terms of kilometers. Their methodology states that anything within the UK is “domestic”, and that flights up to 3,700km are “short-haul”. “Long haul” is over 3,700km. “International” flights are those entirely outside the UK. It’s not clear if flights within Europe are considered international.

Most of the data I will work with are based in the US, so the UK data introduces some additional uncertainty into my calculations. I did find the US Environmental Protection Agency (EPA) emissions calculations, thinking this would be more US-based, but these are actually based on DEFRA. Interestingly, the EPA reports mileage ranges for short, medium, and long haul flights, but I could not find the corresponding DEFRA data (after converting from miles to kilometers). The EPA also did not separate out their emissions by passenger class, so it was not easy to map mileage distinctions to actual emissions.

Given this small amount of uncertainty, I decided to use the DEFRA data, but EPA mileage instead of the to/from UK distinctions:

DEFRA EPA Distance
Domestic Short-haul < 483 km
Short-haul Medium-haul 483 < 3,700 km
Long-haul Long-haul > 3700 km

Where flight class information was not available, I used data from the prior highest class, and when there were no other classes, I used “average passenger” data and labelled it “unknown”.

Working with Airport Data in R

During my research on this project, I found that someone has already made their own calculator in R. Dr. Sheila Saia’s post introduced me to the airportr package that can be used to look up airport codes and calculate distance (using Great Circle Distance) automatically in R.

Sheila also made a function to automatically calculate emissions. However, their calculator used a flat calculation of 0.24 pounds of CO2 per mile. I wanted to have a more accurate number. What I liked about their calculator was that it also calculated carbon offset cost using the EPA’s Social Cost of Carbon Technical Report and fit a linear model to make offset recommendations. This is cool, but beyond what I needed.

The Calculator

The model for the calculator I decided to develop is based on the distance from departure airport to arrival airport for one person. It also accounts for flight class (economy, premium economy, business, first), and allows options for different types of metrics (co2e, co2, ch4, n20). If there are multiple legs in the trip, they can be calculated separately and summed. Likewise for round trips.

The calculator is not a package but a script which can be downloaded from my GithUb repo. It also requires the installation of airportr package and downloading the calculations.RData file. The script will load both. The script then uses the emissions function to calculate emissions based on arrival and departure airports.

Examples

Calculating distance between LAX and Hong Kong:

source("flight emissions calculator.R")
emissions("DEN", "HKK", "Economy")
## [1] 1870.993

We can also calculate distance and add to an existing data frame using mutate and calculate multiple itineraries at the same time. Here is some example data

travel_data <- data.frame(name=c("Mike", "Will", "Elle"),
                          from=c("LAX", "LGA", "TYS"),
                            to=c("PUS", "LHR", "TPA")
                            )

travel_data %>% 
  knitr::kable()
name from to
Mike LAX PUS
Will LGA LHR
Elle TYS TPA

Here is how you can take the from and to data and calculate emissions for each trip:

travel_data %>%
  rowwise() %>%
  mutate(emissions = emissions(from, to, output="co2")) %>%
  knitr::kable()
name from to emissions
Mike LAX PUS 1873.3578
Will LGA LHR 1077.9199
Elle TYS TPA 138.9975

I hope that this calculator is of some use. Feel free to improve it over on Github!

Avatar
Anthony Schmidt
Data Scientist

My research interests include data science and education. I focus on statistics, research methods, data visualization, and machine learning.

comments powered by Disqus

Related