Last active
November 1, 2021 14:32
-
-
Save squeezer44/a98a7ddb088078d1ec312ad0f12c9c45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---------------------------- | |
# Calculate delta | |
# time_delta | |
## calculate and add column time_delta | |
gpx_df['time_delta'] = gpx_df['time'].shift(-1)-gpx_df['time'] | |
## translate the time_delta in seconds | |
gpx_df['time_delta_seconds'] = ((gpx_df['time_delta']. | |
fillna(pd.Timedelta(seconds=0)). | |
view('int64')/1000000000)) | |
# calculate and add column altitude_delta | |
gpx_df['altitude_delta_meters'] = gpx_df['altitude'].shift(-1)-gpx_df['altitude'] | |
# distance_delta | |
dist_great_circle = [0] | |
dist_geodesic = [0] | |
for idx in range(1, len(gpx_points)): | |
start = gpx_points[idx-1] | |
stop = gpx_points[idx] | |
temp_delta_great_circle = distance.great_circle((start.latitude, start.longitude), | |
(stop.latitude, stop.longitude)).m | |
temp_delta_geodesic = distance.distance((start.latitude, start.longitude), | |
(stop.latitude, stop.longitude)).m | |
dist_great_circle.append(temp_delta_great_circle) | |
dist_geodesic.append(temp_delta_geodesic) | |
gpx_df['distance_delta_great-circle_meters'] = dist_great_circle | |
gpx_df['distance_delta_geodesic_meters'] = dist_geodesic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment