2

I have some GPX track files, each containing tracks with thousands of trackpoints.

I need to split those files into multiple ones, each with 500 (or more, accordingly) points each.

Unfortunately I cannot simplify those tracks, I really need to split them.

As long as I could find, gpsbabel isn't able to do so. I am open to use any tool either on Linux (preferably) or Windows as well.

1

Surprisingly it seems gpsbabel indeed can't do it. But at least it can help by first converting to csv. Then I split the result with Unix' split and convert back to gpx with gpsbabel. A similar strategy might work with PowerShell, but I don't know if it has a split equivalent. Here is the bash function I used:

splitTrack() {
  # $1 shall be the gpx file to split
  pfx="${1%.*}-"
  gpsbabel -i gpx -f "$1" -t -o csv -F - \
  | split -d -l 500 --additional-suffix=.csv - "$pfx"

  for f in "$pfx"*.csv; do
    fout=${f%.*}.gpx
    gpsbabel -i csv -f "$f" -x transform,trk=wpt -x nuketypes,waypoints \
             -o gpx -F "$fout"
    rm "$f"
  done
}

EDIT: Added hint from comments about getting track points out instead of way points.

  • Uhm, that generates files with plenty of waypoints though, rather than trackpoints. I tried the transform options described here: gpsbabel.org/htmldoc-1.5.1/filter_transform.html but I was unsuccessful. Would you please have any tip about how to convert the CSV temporary file into a proper track rather than a collection of waypoints? Thanks again – Dakatine Oct 16 '18 at 14:49
  • 1
    found it! gpsbabel -i csv -f "$f" -x transform,trk=wpt -x nuketypes,waypoints -o gpx -F "$fout" – Dakatine Oct 16 '18 at 15:01

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.