2

I need to merge 20-40 GPX files into a single GPX file, while removing waypoints during the process (I only need tracks).

I looked around the GPSBabel GUI application, but found nothing obvious, and the website displays nothing when clicking on either Support or Documentation.

Can the CLI application do this? Or some other Windows application?


Edit: In addition to Oto's Python-based solution below, I found how to use GpsBabel's CLI application to merge GPX files:

SET APP="c:\Program Files\GPSBabel\gpsbabel.exe"
setlocal enabledelayedexpansion
set f=

for %%f in (*.gpx) do set f=!f! -f "%%f"

%APP% -t -i gpx %f% -x nuketypes,waypoints -o gpx -F merge.nuked.gpx

Use "-x nuketypes,waypoints" if you don't care about waypoints.

Important: Make sure the filenames are sequential (eg. 1.gpx, 2.gpx, etc.) so that the route makes sense.

1

Do you Python? I've written a partial solution to your problem in Python using the GpxPy library. It should show you how to create your own custom solution. In my case I am extracting the track from a gpx and outputting it to a formatted text file.

import gpxpy
import gpxpy.gpx
import datetime

# Parsing an existing file:
# -------------------------
gpx_file = open(r'C:\Current.gpx', 'r')

gpx = gpxpy.parse(gpx_file)
with open(r'r'C:\Projects\mytrack.txt', 'w') as f:
    f.write('bla bla') 
    f.write('/\n')
    f.write('/Date   Time   Latitude   Longitude   Elevation\n')

    for track in gpx.tracks:
        track.adjust_time(datetime.timedelta(hours=-6))
        for segment in track.segments:
            for point in segment.points:
                newtime = point.time - datetime.timedelta(hours=6) 
                f.write('{0} {1} {2} {3}\n'.format(point.time,  point.latitude, point.longitude, point.elevation))
  • Thank you very much. The problem what two-fold: 1) Use full-path to application, and 2) Name filenames sequentially so that the route makes sense. – Gulbahar Mar 13 '17 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.