Visualizing Outdoor Activities with Python Folium
Embark on an expedition of exploration and mapping! Learn how to breathe life into your GPX files and create interactive maps using Python and Folium.
Introduction
I dream of hiking from Munich to Venice, trekking across the beautiful Alps. But as I still have to live my everyday life, my journey has to consist of multiple stages, with weeks, months, or even years between each adventure. That is ok, as it’s more about the journey than the destination. However, I always wanted a way to visually retrace these paths, to see how far I’ve come and how close I am to my goal. I wanted a way to celebrate the progress I’ve made and to motivate myself to take the journey further.
Fortunately, many outdoor and sports apps, like Adidas Running, Komoot, Strava, and others, graciously allow us to export our activities as GPX files. However, there’s nowhere to go with those GPX files.
That is where Python and Folium come into play. I recently stumbled upon Folium, a powerful Python library for creating interactive maps. It can easily incorporate geographic data, such as the GPX files, and allows for customization and exploration. Drawing upon the wealth of GPS data I’ve gathered, I started experimenting with Folium to craft a map that brings my outdoor excursions to life.
After some research and a lot of testing, I came up with a map that allows me to revisit my past outdoor activities:

So, if you are anything like me and have a treasure trove of GPS data without any purpose, you may wonder how I got there. So in this story, I will explain how to breathe life into your GPX files. Let’s embark on an expedition of exploration and mapping!
Getting Started with Jupyter Notebook
To begin this adventure, we’ll be using Jupyter Notebook. Why Jupyter Notebook? It’s a fantastic interactive computing environment that allows us to combine code, visualizations, and text, making it perfect for experimenting with our data and the Folium library.
If you haven’t installed Jupyter Notebook yet, follow the instructions on their official website. Once installed, you can create a new Jupyter Notebook and get ready for your journey.
Parsing GPX Files for Trail Data
Next, we need the raw material for our map — the GPX files. GPX (GPS Exchange Format) is a widely-used file format that stores location data, such as latitude, longitude, elevation, and time, making it ideal for tracking outdoor activities.
If you’re an avid hiker, runner, cyclist, or skier, chances are you already have tracked various excursions using an outdoor or sports app. Plenty of those apps allow you to export your activities in GPX format. So gather those GPX files, and let’s get started!
In our Python code, we’ll use the gpxpy
library to parse the GPX files and extract the essential trail data, such as latitude, longitude, elevation, speed, and distance. The parse_gpx()
function will do all the heavy lifting for us: