Created
August 26, 2020 15:17
-
-
Save KimuraTakaumi/924cc475d18a8b7a2e11af10f00ca342 to your computer and use it in GitHub Desktop.
GPX内の移動を停止した場所にウェイポイントを打つ
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
import gpxpy.gpx | |
gpx_file_r = open('input.gpx', 'r') | |
gpx = gpxpy.parse(gpx_file_r) | |
speed = [] | |
pick = True | |
data = [] | |
for track in gpx.tracks: | |
for segment in track.segments: | |
for point in segment.points: | |
if point.speed < 1.0 and pick: | |
data.append(point) | |
speed.append(point.speed) | |
pick = False | |
elif point.speed >= 1.0: | |
pick = True | |
count = 0 | |
for d in data: | |
w = gpxpy.gpx.GPXWaypoint() | |
w.latitude = d.latitude | |
w.longitude = d.longitude | |
w.comment = "point" + str(count) | |
w.name = "point" + str(count) | |
w.description = "point" + str(count) | |
gpx.waypoints.append(w) | |
count = count + 1 | |
with open("output.gpx", "w") as f: | |
f.write(gpx.to_xml()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment