How to get the API to return Altitude

Is there any way i can get information about the altitude from a round trip route? I am looking to get information about Elevation and Segment Length and on the API playground i dont see any information to get this. There is an option for elevation which is a boolean but i dont see it appearing on the route when i am hovering over it. There is also avoid segments but i would like to know the distance for each segment.

Hi @Williamk28,

if you use the https://api.openrouteservice.org/v2/directions/foot-walking/geojson endpoint, all the information you need should be contained in th response.
However, the distance is only calculated for the segments and (navigation) steps of the route.
If you want the segments by extra information (waytype, surface etc.) you need to calculate this yourself by using the points of the geometry the extra info points to.

But that’s also a feature that could be added to the heightgraph (elevation model on the picture), to calculate segment distance and ascent/decent for the selected segment.

You can open an issue there, but it’s currently not being worked on.

Best regards

So to get the elevation i would use the extra information “steepness” which should return the elevation for each segment? I am not aiming to use the heightgraph shown in the picture, i just would like the information it provides.

The elevation can be returned when setting elevation=true it will be part of the geometry for each point.
The steepness segments can be returned with the extra_info.
A roundtrip request for this would look like this:

  curl -X POST \
  'https://api.openrouteservice.org/v2/directions/foot-walking/geojson' \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Accept: application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8' \
  -H 'Authorization: your-api-key' \
  -d '{"coordinates":[[8.691495,49.42461]],"elevation":"true","extra_info":["steepness"],"options":{"round_trip":{"length":3000,"points":3}}}'

The incline/decline category segments are in the response in routes.extras.steepness.values

[0,  <- start point index of the segment (1st point of line geometry)
 14, <- end point index of the segment (13th point of line geometry)
 -2] <- value of the segment

the value resolves to the categories listed on

For the steepness response, i noticed that in routes.extras.steepness.summary it returns value, distance and amount. What is amount? Amount provides a number so is this the elevation in metres for the distance it has returned? So if the distance is 1000 and amount is 64, is that the elevation of the next 1000 metres?

Hey,

the steepness summary sort of groups the various sections by value and gives the total distance and the relative amount (in percent) of the route that has this value.

Look at the following example summary for a route with total length 1372.1.

"summary":  [
  {
      "value":  3 ,
      "distance":  1037.4,      <- Distance of route parts with value 3
      "amount":  75.61          <- relative amount (75.61% * 1372.2 = 1037.4)
  }, 
  {
      "value":  2,
      "distance":  251.7,
      "amount":  18.34
  } ,  
  {
      "value":  1,
      "distance":  83,    
      "amount":  6.05 
  }
]                 

I hope that makes this a bit clearer.
Best regards

So that would mean for 1037.4m of the route, there is an increase of 7-11% of steepness of the route since value 3 = 7-11%

Precisely :slight_smile:

1 Like

Setting Elevation to true returns a value in the geometry, is this the elevation the coordinate is currently on in metres? It also returns properties which has “ascent: 5.7” and “descent: 6.1” does this mean the route has a total ascension of 5.7m and 6.1m descension from the start until finish of the route. How are these calculated?

Hey,

when you state that it

which endpoint (default, geojson, json,…) are you using?
In any case, this should be the elevation of that point, yes.

Ascent and descent should be the total ascent and descent of the route.
They are calculated by summing the differences of the elevation of sequential points on the route.

Best regards

I am using the geojson endpoint. In geometry it returns coordinates which contains the longitude, latitude, and elevation i believe. Is the elevation returned in metres?

Yes, the third value is elevation in metres.

When setting Elevation to true, it returns “bbox” with an array of 6 items which are the starting and end position of the coordinates and elevations. Im unsure why my starting point of elevation is 10 and the elevation at the end is 15. I am using roundtrip feature so shouldn’t the elevation be the same since you start and finish at the same place?

hi @Williamk28,
the bbox is not the start and end of your route but the minimum bounding box that contains the whole route geometry.
So the lowest and highest values in x,y and z direction that the route geometry touches.

Although there are some issues with the elevation e.g.

that are still unresolved