Better OSRM Routes
OSRM recommends the shortest route between start and destination. This may not be the route you want to take when going out for a walk or a run. OSRM simply has no way of knowing your preferences.
Is there a way to create routes with OSRM which take into account the streets and places you like to visit? One approach is to create custom OSM ways which represent your favorite routes.
You can use heatmaps Garmin Connect or Strava to get popular GPX tracks. To connect GPX files with the OSM map you need to know which OSM nodes are present in the GPX files. This will allow adding new OSM ways to make OSRM prefer your GPX routes.
Here is an example of what you can achieve with this approach:
You can see details of how to get this done in my Github repo.
Get Evgeny Arbatov’s stories in your inbox
Join Medium for free to get updates from this writer.
This is what you need to get started:
- OSM extract for your city / area you are planning to run in
- Set of GPX files which represent your favorite routes
On a high-level, these are the steps:
- Get OSM nodes for GPX files using OSRM nearest service with a script which goes over each GPX coordinates and calls OSRM API for it
- Create OSM ways using nodes from the previous step and set custom names to differentiate the new ways from all other OSM ways
- Merge OSM ways based on GPX file with the public OSM map
- Create new OSRM profile which prioritizes GPX-based OSM ways
- Launch a separate OSRM instance with the new profile
- Use OSRM routing service to get route recommendations and save them as GPX files.
The results are not perfect but it’s a good start.









