Best approach to simplify gpx file?

875 views
Skip to first unread message

Kevin Price-Ward

unread,
Jul 25, 2018, 12:14:04 PM7/25/18
to Strava API
Hi,

I'm building a new runners membership site which allows members to sync their runs from strava via the api and also to upload gpx files that may be on their garmin device or similar.

As a test I have exported a gpx file from Strava but I'm finding that it's huge. It seems that there is a single <trkpt> node for every second of the activity - is that normal? Is it a feature of the gpx format that there is a node for every second?

I'm looking to store this data in a database because I'd like to be able to plot the run on a Google map, but I feel that storing all of this data would be overkill. If I took say one in every 10 nodes and just stored the lat, lng and elevation in a json object, would that work? Obviously the resultant line on the map would be a 10th as detailed but I'm only trying to give an overview of the route anyway.

If I apply this logic to all uploaded gpx files, it would rely on them all being as detailed - a node for every second, otherwise it wouldn't work!

Would appreciate your thoughts
Kevin

Evgenii Sovetkin

unread,
Jul 25, 2018, 12:21:17 PM7/25/18
to Kevin Price-Ward, strav...@googlegroups.com
> As a test I have exported a gpx file from Strava but I'm finding that it's
> huge. It seems that there is a single <trkpt> node for every second of the
> activity - is that normal? Is it a feature of the gpx format that there is a
> node for every second?
>
> I'm looking to store this data in a database because I'd like to be able to
> plot the run on a Google map, but I feel that storing all of this data would be
> overkill. If I took say one in every 10 nodes and just stored the lat, lng and
> elevation in a json object, would that work? Obviously the resultant line on
> the map would be a 10th as detailed but I'm only trying to give an overview of
> the route anyway.
>

I have similar problem with my garmin foretrex device. Very often it
is not enough memory to upload the route.

A standard tool to reduce the size of gpx files is, in my opinion,
gpsbabel. It has a simple command line interface, and a command like
this

gpsbabel -r -i gpx -f input.gpx -x simplify,count=250 -o gpx -F output.gpx

will do the job reducing route to 250 points.

Cheers,

Jenya
signature.asc

Jeffrey Friedl

unread,
Jul 25, 2018, 12:38:02 PM7/25/18
to Kevin Price-Ward, Strava API




> It seems that there is a single <trkpt> node for every second of the activity - is that normal?
> Is it a feature of the gpx format that there is a node for every second?


Yes, this is common. Some devices record at 10Hz (10 nodes per second), and some much less... sometimes
there's a setting to record based upon movement.

In any case, you can simplify as much as you like. GPSBabel has routines that are pretty smart about it.
https://www.gpsbabel.org/

Jeffrey
Reply all
Reply to author
Forward
0 new messages