Skip to content

Instantly share code, notes, and snippets.

@KimuraTakaumi
Created August 26, 2020 15:17
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 KimuraTakaumi/924cc475d18a8b7a2e11af10f00ca342 to your computer and use it in GitHub Desktop.
Save KimuraTakaumi/924cc475d18a8b7a2e11af10f00ca342 to your computer and use it in GitHub Desktop.
GPX内の移動を停止した場所にウェイポイントを打つ
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