You can visualize latitude and longitude points as a scatter plot with Matplotlib - longitude on the X-axis, and latitude on the Y-axis.
How to Visualize Strava Routes with Matplotlib
Let’s start with Matplotlib and discuss why that isn’t a good idea. There are 835 data points available in the dataset, which is more than enough for a representative route visualization. Route_df.head() Image 1 - Strava route dataset (image by author) You can now load the route dataset: route_df = pd.read_csv('./data/route_df.csv') To start, we have to import a couple of libraries - Pandas and Folium primarily - but also Matplotlib for a basic route visualization: import folium We won’t bother with GPX files today, as we already have route data points extracted to a CSV file.
You can download the source code on GitHub. Let’s begin.ĭon’t feel like reading? Watch my video instead:
Install it with Pip if you haven’t already (pip install folium). We’ll start visualizing Strava routes with Matplotlib, but we’ll quickly transition to a more specialized library - Folium. Today you’ll use these points to draw the route on a map! You’ve also exported your Strava route in GPX format, loaded it with Python, and extracted key data points, such as latitude, longitude, and elevation. Last week you learned all about GPX data. which sorted out that particular issue.Part 2/6 - Visualize Strava routes easily with amazing Python libraries No worries – Strava has a “refresh my achievements” tool. Just one thing to sort out – all of the PRs I got on today’s ride (and there were a few) were recorded as second places by the second upload. I then deleted the original (short) ride from Strava and re-uploaded. it would probably have worked with my edited files but I could also merge them in the GPS Track Editor…
I also tried merging the files with a tool from – unfortunately, that ended up with a ride that was effectively double the length of what we rode (two loops). Using this, I could edit Andy’s data to just the part I had missing, then combine it with mine and merge the two tracks (the short gap doesn’t matter – Strava will straight-line the route between the two points). I’ve blogged before about GPS Track Editor, which is a fantastic piece of free software. Even though he’d also forgotten to start his, he was wearing a Garmin watch too – so I could combine his data and mine (we’d ridden side by side for the first part of the ride…). It would be able to cope with turning around, going back up the hill, starting the computer and starting the ride again – but not with some missing kilometres in my ride data! Luckily, Andy was also riding with a Garmin bike computer. Unfortunately, my ability to “press the start button on my Garmin cycle computer” is clearly less good – I was about a mile from home and heading out of town when I realised I’d forgotten to start tracking my ride! It seems my route planning is pretty spot on, as it was almost the exact opposite of a charity ride going the other way around (we passed the same riders twice!). My friend Andy and I put in 60 miles in the sunshine, on a big loop around Milton Keynes. This morning was spent on my bike… as was a fair chunk of this afternoon… as is a fair chunk of many summer weekends, much to Mrs W’s disappointment. Please be warned that the information here may be out of date.
I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time.