Skip to content

Instantly share code, notes, and snippets.

@WouterNieuwerth
Created February 9, 2020 13:50
Show Gist options
  • Save WouterNieuwerth/9339cbeb3c75ee94b17f669b682d5a70 to your computer and use it in GitHub Desktop.
Save WouterNieuwerth/9339cbeb3c75ee94b17f669b682d5a70 to your computer and use it in GitHub Desktop.
GPX analysis - step 6
# Calculate distances and time deltas
df['distance_dis_2d'] = df.apply(lambda x: distance.distance((x['lat-start'], x['lon-start']), (x['lat'], x['lon'])).m, axis = 1)
df['alt_dif'] = df.apply(lambda x: x['alt-start'] - x['alt'], axis=1)
df['distance_dis_3d'] = df.apply(lambda x: sqrt(x['distance_dis_2d']**2 + (x['alt_dif'])**2), axis=1)
df['time_delta'] = df.apply(lambda x: (x['time'] - x['time-start']).total_seconds(), axis=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment