Recent Changes - Search:

add Cookbook page







Visitor's book Site map pmwiki-2.3.30

Gpx Stat

To do
  • change skiwi
  • remove this comment

GpxStat version 2024-02-06

Summary: A recipe to display statistics about a GPX file
Version: 2024-02-06
Prerequisites: PmWiki 2.3.29; PHP 8
Status: Beta
Maintainer: skiwi
Licence: GPL3#
Categories: Maps Markup Includes
Users: (view / edit)
Discussion: GpxStat-Talk

Questions answered by this recipe

How can I display information from a .gpx track file?


This recipe extracts and derives information from a .gpx file. Information available includes times, duration, speed, and elevation.

It provides a single line directive that implements a display of information contained in, and derived from, .gpx file .

(:gpxstat gpx="wiki file name" display="layout" timezone="time/zone":).

The recipe uses a simple sliding window algorithm to remove outlier points and smooth the trace. An empirical 2.5 standard deviations from the average of the variation between points is used to set a threshold outside of which points are replaced by an estimated value.

Different layout outputs can be selected to show the information relevant to the activity that generated the track. Output is tabular.



Place the directive, as follows, in your PmWiki page.

(:gpxstat gpx='GroupName.PageName/filename.gpx' display='table,analyse' timezone='time/zone':)

Parameters are

this parameter is mandatory, the groupname and pagename are optional
this parameter is optional. Layout values are
  • table (of all available values)
  • tramp (i.e. walk)
  • ski
  • drive (also boat, fly in case these are differentiated in the future)
  • analyse (to assist with understanding the .gpx file)
default if not supplied all available values are displayed in a column
this parameter is optional. Set the speed in km/h below which points count as stopped, overrides default and config value if specified
this parameter is optional. Timezones recognised are those from the IANA / Olson timezone database. A conversion from timezone abbreviations is also attempted. You can also try the keyword 'detect' to calculate the timezone from the first point on the track, YMMV.
startname="location name"
this parameter is optional. Replaces the text "Start:"
endname="location name"
this parameter is optional. Replaces the text "End:"
banner="on", "off", or "version"
this parameter is optional. Enables (default), disables, or shows banner with version

GPX track files do not always comply with the GPS exchange format standard. This recipe takes precautions to handle some variances. If you have a .gpx file that does not work as expected with this recipe please send it for analysis with a description of the issue.

Example output


GpxStat 2024-02-06
Distance: 13.6 km
Max speed: 1.3 km/h
Avg dsc speed: 3.0 km/h
Avg asc speed: 1.8 km/h
Avg moving speed: 2.5 km/h
Avg speed: 2.3 km/h
Min elev: 0 m
Max elev: 470 m
Start elev: 220 m
End elev: 210 m
Elev loss: -10 m
Ascent: 1,570 m
Descent: 1,599 m
Start: 08:33
End: 14:22
Elapsed: 05:49 h
Duration: 05:49 h
Duration moving: 05:22 h
Duration ascent: 02:17 h
Duration descent: 01:26 h
Duration stopped: 00:26 h
# Points: 2,987

Track date (NZDT): 2020-09-30
Track name: Example GPX track
A walk in the hills
Track desc: Example for PmWiki GpxStat recipe
File: " track.gpx"


Start: 08:33 Start elev: 220 m Max elev: 470 m Distance: 13.6 km
End: 14:22 End elev: 210 m Ascent: 1,570 m Avg moving speed: 2.5 km/h
Duration: 05:49 h Elev loss: -10 m Descent: 1,599 m Duration moving: 05:22 h


Track name: Example GPX track
A walk in the hills
Track desc: Example for PmWiki GpxStat recipe
Distance: 13.6 km Avg speed: 2.3 km/h Start elev: 220 m
Ascent: 1,570 m Avg moving speed: 2.5 km/h Min elev: 0 m End elev: 210 m
Descent: 1,599 m Max speed: 1.3 km/h Max elev: 470 m Elev loss: -10 m
Duration: 05:49 h Duration moving: 05:22 h Duration stopped: 00:26 h GpxStat
Start: 08:33 End: 14:22 Track date (NZDT): 2020-09-30 Time zone: Pacific/Auckland
# Points: 2,987 Threshold speed: 0.8 km/h
File: " track.gpx"


config.php settings

You can set the following in config.php before including the recipe. for example:

$GpxStatDebug = true; # results may vary
$GpxStatThresholdSpeed = 1; # 1 km/h under which it is considered to be not moving
$GpxStatDTimeFmt = 'H:i'; # e.g. 'Y-m-d T H:i:s'
$GpxStatDateFmt = 'Y-m-d'; # e.g. 'Y-m-d T H:i:s'
$GpxStatBanner = 'on'; # 'off', or 'version'

CSS style

The class ".gpxstat" is used to format the output. A default set of formatting is provided in $HTMLStylesFmt['GpxStat'] = '.gpxstat { ... }';. Defining this variable in config.php before the recipe is included will override the defaults.

Change log / Release notes

2024-02-06 Add average descent/ascent speed for skiing 2024-01-10 Add directive parameters (startname, endname, stoppedthreshold), update analyse output, handle no timestamps in GPS file, correct display of duration 2024-01-01 Initial version

See also

A handy companion to

Similar utilities and information

Used on



See discussion at GpxStat-Talk

tahi Page last modified on 2024 Feb 06 21:56

Edit - History - Recent Changes - WikiHelp - Search - email page as link -> mailto:?Subject="KiwiWiki: Gpx Stat"&Body=