Creating a Marathon Course GPX
GPX files are common for ultra runs but less so for marathons. After all, you’re unlikely to get lost running a marathon, right?
Creating a Marathon Course GPX
GPX files are common for ultra runs but less so for marathons. After all, you’re unlikely to get lost running a marathon, right?
I’d argue that having a GPX is still useful — it lets you explore points of interest along the course and better prepare for race day. If your race organizer doesn’t provide one, here’s how you can create it yourself.
The most straightforward approach is to use gpx.studio and trace the route using the bike or car profile. It’s tedious, but if you’re working with a new course, this is probably your easiest option.
When I tried plotting the first 12km using the pedestrian profile in gpx.studio, I ended up with a route that followed pedestrian paths instead of roads. This wasn’t ideal — I wanted my GPX file to match the actual course exactly.
Using a public OSRM instance wasn’t an option for matching GPX files with 2,000+ points, so I set up my own OSRM instance with Docker using an OSM map extract bounded by the GPX file I’d assembled.
You’d think I could simply use OSRM’s match service to get the correct GPX file, but OSRM respects street directions by default and created all kinds of detours from the original route:

I experimented with using the bicycle OSRM profile for some segments, which worked well — until I hit highways that don’t allow bicycles:
It turns out there’s a single OSRM profile parameter that allows the car profile to ignore road directions and match GPX files closely to the original:
- oneway_handling = true,
+ oneway_handling = false,
My manual plotting had introduced several points that weren’t aligned to roads, causing OSRM to include detours like this one:

I preprocessed the GPX file to remove these outliers, then used OSRM’s match service. The result? A perfectly matched GPX route:



The final challenge was elevation. OSRM’s matched GPX file doesn’t include elevation data for each point. Open Elevation API is an option, but it averages elevation and won’t give you precise readings — like the exact elevation of a bridge over a river.
My solution was to use a GPX from a previous marathon I’d run on a similar course, approximating the new course’s elevation based on the nearest points from the old one. This worked reasonably well.
Using Strava’s handy elevation correction feature on my past activity, I generated a smooth, realistic-looking elevation profile:

Here’s the resulting GPX file if you want to check it out. It’s far more accurate than anything you’d record with a phone or watch!
메타데이터
- post_id
- 8d1029e03e2d
- slug
- creating-a-marathon-course-gpx-8d1029e03e2d
- url
- https://medium.com/@arbatov/creating-a-marathon-course-gpx-8d1029e03e2d
- canonical_url
- https://medium.com/@arbatov/creating-a-marathon-course-gpx-8d1029e03e2d
- author_url
- https://medium.com/@arbatov
- status
- ok
- fetched_at
- 2026-06-12 22:02:08