Lately, I've found myself diving deeper into the world of calculating my lifetime carbon footprint. This has led me to explore the environmental impact of my travels, particularly the carbon emissions from flights.

Not only was I counting the number of countries I’ve visited, I wanted to take a closer look at the carbon footprint left by my flights. For this, I meticulously documented every flight I've taken over the years to calculate the total carbon emissions. For actually calculating the emissions, I plan on using the excellent library co2calculator. However, along the way I got side tracked by another interesting project of visualizing my flight paths and specifically using D3 library in java script. This was inspired from the famous facebook showing connected friends.

To bring my data to life, I first documented (almost) all my flights (by flights I mean the name of the city from, to and layover city) in a simple "Numbers" file (Apple FTW). A key challenge in this project was accurately converting city names into exact airport locations. This involved translating city names into IATA airport codes and then into latitude and longitude coordinates. For this, I wrote a simple parser in python to read this file and used the airportsdata library to get the coordinates. This process is far from perfect and routinely results in flights that I havent't actually taken, leading to some unexpected routes appearing on the map.

(Edit: I think this problem was over-engineered. I have now decided to skip the city-to-airport mapping, as it was not a deterministic solution. Besides, on a map of the world, the paths look almost identical for various airports. Instead, I decided to just use the location of the city that I get from geopy.)

A simple CSV file is written out and is read by the java script code to plot the great circle path. Coming from the tropics I cannot be a fan of the Mercator projection so the map below uses the Natural Earth projection instead. During this process I also read two excellent blogs (here and here) about geoJSON format and this excellent resource for downloading map data in geoJSON. It also got me wondering that creating this would also be required to have an "official" map for each country/entity and of course, I found one for the EU.

Anyway, despite these challenges of getting the correct airports from city names, I’m refining the script to ensure greater accuracy. Once these issues are ironed out, I am hoping the data pipeline will automatically update the map with corrected data, making it a reliable tool for visualizing future travels.

I realize the title of this blog is a bit misleading though, because the actual calculation of my carbon footprint is not here. I am keeping this for a future post as part of a more comprehensive carbon footprint calculation.

Here's a glimpse of the map I created, highlighting the paths my flights have taken: