Skip to content

Instantly share code, notes, and snippets.

@lmeulen
Last active August 24, 2021 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmeulen/66d23219ab89558a64b422cd1545d41d to your computer and use it in GitHub Desktop.
Save lmeulen/66d23219ab89558a64b422cd1545d41d to your computer and use it in GitHub Desktop.
gpx_elevantion_v1
df.loc[0, 'delev'] = 0.0
for i in range(1, len(df)):
df.loc[i, 'delev'] = (df.loc[i, 'elevation'] - df.loc[i-1, 'elevation'])
descent = abs(df['delev'].where(df['delev']<0).sum())
ascent = df['delev'].where(df['delev']>0).sum()
minelev = df['elevation'].min()
maxelev = df['elevation'].max()
print('Minimum elevation : {:4.0f} m'.format(minelev))
print('Maximum elevation : {:4.0f} m'.format(maxelev))
print('Total ascent : {:4.0f} m'.format(ascent))
print('Total descent : {:4.0f} m'.format(descent))
'''
Output:
Minimum elevation : 13 m
Maximum elevation : 68 m
Total ascent : 154 m
Total descent : 159 m
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment