total_elevation_gain! What about total_elevation_loss?

492 views
Skip to first unread message

David Marks

unread,
Feb 9, 2021, 12:38:00 PM2/9/21
to Strava API
I see in the detailed activity there is a total_elevation_gain but I don't see total_elevation_loss?  I guess I could use a what goes up must come down logic, but that seems wrong.  If you started a hike on a bluff and ended at the beach it's all loss not gain.

I also could use the altitude stream and calculate it, but Strava smooths for the total elevation gain.

Thoughts anyone?  Am I missing something?

David

Jan Szewczak

unread,
Feb 15, 2021, 12:38:27 AM2/15/21
to Strava API
Hey,

I had a very simple activity


basically, test cadence and on strava, I had 9m of total elevation on strava for me its means I had -9 total elevation and +9 total elevation and strava save 9 only.

probably you should get gpx/fit file and count elevation based on this data.

I can check that ride down this path and see what elevation show up on strava.

Jan Szewczak

unread,
Feb 15, 2021, 2:33:02 AM2/15/21
to Strava API

On second thoughts see
https://en.wikipedia.org/wiki/Cumulative_elevation_gain
this is what strava count as total_elevation_gain

but what happens when you ride down only from 118m to 108m elevation?
see on:
https://www.strava.com/activities/4789574506

So count only as 0 elevation gain because I don't gain any elevation means not go uphill


Luis

unread,
Nov 4, 2021, 2:48:18 PM11/4/21
to Strava API
Hi David Marks,

the  total_elevation_gain is deffined in the first level when you get the activity from Strava API with the "Get Activity" function for example. 
But the elevation_loss is only available in the "splits_metric" array, which is in the first level of the activity. It is an array with as many splits as laps, and in each split there is a "elevation_difference" field in which you can get the positive or negative elevation from the start of the split to the end. So if you need the total elevation loss for the current activity, you can loop the "splits_metric" array and get it.

Hope it helps! Kind regards,
Luis

Oliver Kurth

unread,
Nov 4, 2021, 3:42:30 PM11/4/21
to Luis, Strava API
You can just calculate it from elevation_gain like this:

elevation_loss = min(0, elevation_gain + (elev_start - elev_end))

elev_start and _end are just the elevation of the first and last points respectively.

Oliver



--
You received this message because you are subscribed to the Google Groups "Strava API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to strava-api+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/strava-api/e23e5f36-1350-4e46-9947-3064b4c799c8n%40googlegroups.com.

Luis

unread,
Nov 4, 2021, 3:47:27 PM11/4/21
to Strava API
Hi Oliver, 

yes, could be an alternative, but the "elev_start" and "elev_end" are on the segments array, no? Are they the "elevation_high" and " elevation_low" the ones you meant?
I cannot find "elev_start" on the Strava API.

Kind regards,
Luis

Jan M.

unread,
Nov 6, 2021, 4:27:48 PM11/6/21
to Strava API
Hi Luis, I think your way of totaling all the  "elevation_difference" from the splits_metric and adding the total to the elevation_gain is the easiest way to calculate the elevation loss. With Olivers method we would need an additional API like the Google API to get the elevation from the start and end of the activity.

Oliver Kurth

unread,
Nov 6, 2021, 4:48:49 PM11/6/21
to Jan M., Strava API
No, you can get the elevation using the activity streams, see  https://developers.strava.com/docs/reference/#api-Streams-getActivityStreams and https://developers.strava.com/docs/reference/#api-models-AltitudeStream . Looks like the stream type is "altitude" (not "elevation" as one might expect). Use the first and last values.

Btw, I made a mistake in the equation - it should be max() not min():

elevation_loss = max(0, elevation_gain + (elev_start - elev_end))

Oliver

Maggie Lonergan

unread,
Jan 9, 2022, 8:55:39 PM1/9/22
to Strava API
I'm trying to get the total vertical loss for alpine skiing activities and tried the split_metrics method mentioned above. I found that the field splits_standard was probably what the laps view on strava is showing (e.g., on a day with 4 runs, there are 6 splits in split_metrics and 4 in splits_standard). However, I cannot figure out how strava computes vertical feet for skiing activities. I think the methodology above is sound, and when I tried it I managed to match the numbers I see on the activity's laps page, but the total vertical feet metric does not appear to be related. In this case, the total elevation difference for all splits is ~1000ft, whereas each run should be that height.

Any ideas on where the vertical feet metric used for alpine skiing comes from?

Thanks!
Maggie

Reply all
Reply to author
Forward
0 new messages