1

How to join GPX files? (Read 908 times)


Options,Account, Forums

    This isn't necessarily for Eric; it is for anyone familiar with GPX files who cares to answer.

     

    I'd like to join two GPS tracks -- from the same run, in two segments recorded on two watches. They're not quite contiguous -- the first track covers perhaps 25mi, and the second track covers perhaps 20mi, and there is some gap between them. (But I hope that doesn't matter.)

     

    I obtained (or will obtain) these by uploading from a watch to RA, then saving as GPX. I've only obtained one so far, actually.

     

    It looks like this:

    <?xml...>

    <gpx...>

    <metadata>

    <time>...</time>

    </metadata>

    <trk>

    <trkseg>

    <trkpt lat="..." lon="...">

    <ele>...</ele>

    <time>...</time>

    </trkpt>

    ... (lots more trkpt elements, just like the above one

    </trkseg>

    </trk>

    </gpx>

     

    So, each point has a latitude, a longitude, and a time (and whatever an ele is).

     

    So my question is: how can I attach the second set to the first set?

     

    I will produce it the same way, so I expect to get another sequence of track points (trkpt), and just need to figure out how to concatenate them to what I already have.

     

    Should I dump another track after the first one, copying in the entire trk element? Or should I copy only the entire track segment (trkseg) element into the same track element?

     

    What is the purpose of the metadata time element -- do I need a second at the start of the second track, if I do an entire other track?

     

    Every point has time anyway, so I don't know really why the metadata time is very useful.

     

    Judging by this schema, http://www.topografix.com/GPX/1/1/gpx.xsd

    it appears to me that there can be multiple tracks, and a track can have multiple track segments.

     

    I don't know what difference it would mean logically whether I record the two parts of the run as one track with two segments, or as two tracks.

    It's a 5k. It hurt like hell...then I tried to pick it up. The end.


    Options,Account, Forums

      I've just realized that each track segment is a "lap".

      It's a 5k. It hurt like hell...then I tried to pick it up. The end.


      12 Monkeys

        Right.

         

        Been a while since I have done this, but I have just opened in a text or XML editor and appended the trk nodes from one file to the other:

         

        <?xml...>

        <gpx...>

        <metadata>

        <time>...</time>

        </metadata>

        <trk>

        <trkseg file a>

        <trkpt lat="..." lon="...">

        <ele>...</ele>

        <time>...</time>

        </trkpt>

        ... (lots more trkpt elements, just like the above one

        </trkseg>

        <trkseg file b>

        <trkpt lat="..." lon="...">

        <ele>...</ele>

        <time>...</time>

        </trkpt>

        ... (lots more trkpt elements, just like the above one

        </trkseg>

         

        </trk>

        </gpx>

        jpdeaux


          Darn. Too slow. But yeah, something like that.

          When I did it I think I used output directly from Garmin Training Center, and it combined nicely.


          Options,Account, Forums

            It worked. Thanks. It's funny that the laps are no longer exactly 1mi each, but that's ok.

            It's a 5k. It hurt like hell...then I tried to pick it up. The end.