How to break a route into Segements


I am pretty new to this service - but after plaything and searching, I was not able to find what I am looking for. Sorry if it is a repeated question that I missed on my hunting.

I am working on a project for a bike event, for route distance and segment calculations and live tracking during the event. Essentially, we are looking to break a specific time for this race and being able to break into smaller segments allows the team to be more accurate with their metrics. I could do this manually by continually plugging in lon/lat values until I get what I need, but thought there would be a more elegant solution.

Auto route segmentation:

  • Given a known route I want to break it into segments of say 10km each. I have been trying the direction endpoint with a set of coordinates, but I wasn’t sure how to break this down into segments of a specific size.
    • Is there was a way to get a result set of ALL the lon, lat, distance on a given route? Currently the result set is the distance between the coordinates that I passed in or distance between calculated coordinates, but I am looking for more points along the route, not just the ones defined by route. If the exact segment distance I need is not available, is it possible to have the API return the routes.segments[] in 100meter or 500meter increments, even if there is no route change - that way I could still calculate what I need.



the ors always returns a route as a list of coordinates that are connected by straight segments - either as an encoded polyline or more visible using the geojson endpoint (insert any geojson response into and change the type to “MultiPoint” and you’ll see all the points).

The “segments”-part of the response then has distances and durations between certain waypoints (pertaining to instructions). You can calculate distances between all other waypoints simply using their coordinates and something like geopy.distance.distance. This should enable you to break your route down into smaller 100 meter or 500 meter segments as you like.

Best regards

1 Like

Thanks - this is exactly what I was after.