Metric Trails
Contents

Part III

The Metric Trails method

The method treats a trail as a fixed object in three dimensions and every GNSS track as a noisy observation of it. A track becomes comparable only after it has been cleaned, resampled to a known spatial resolution and given elevation from a common model. The MT standards name the resolution a track supports, the GPX Audit checks it, and the metrictrails R package does all of it in the open.

Trails as reference objects

In short

A trail does not change from one lap to the next; the measurements do. The trail is treated as a stable 3D object, built once with a careful protocol, and every GNSS track is treated as a noisy observation that must be anchored to it.

Why a reference is needed

Mountain terrain imposes gradients, roughness and exposure that no treadmill or level track can reproduce, and these change gait, pacing and cardiorespiratory load. Studying how people move outdoors therefore needs accurate models of the terrain and of the trail itself. Laboratory studies control speed and slope; outdoor studies usually rely on consumer GNSS and platform routes, with unknown filtering and elevation corrections, and different ways of mapping the same trail give different distances, slopes and elevation gains (Sanchez et al., 2025b; Sanchez, 2025).

Repeated laps of the same 1 km segment make the problem visible. The measured distances form a spread rather than a single value, and overlaid raw tracks wander around the same physical trail even when the runner follows it exactly. Most of that lateral spread is GNSS uncertainty and sampling, not route choice. Averaging many tracks into a heatmap does not solve it, because averaging blurs the detail of the trail along with the noise. Distance becomes a stable property of the trail only when measurements are anchored to a common reference model (Sanchez, 2025).

Building the reference

The reference model of a trail combines three ingredients (Sanchez et al., 2025b):

  1. Repeated laps recorded under good conditions with a dual-frequency receiver mounted with a clear view of the sky.
  2. Quality auditing of every reading, using the raw observations of the receiver (RINEX) and precise satellite orbits and clocks to estimate the 3D uncertainty of each reading, and keeping only laps where that uncertainty stays below 0.45 m.
  3. High-resolution elevation from a lidar DEM, after resampling the horizontal track to a uniform 1 m spacing.

On Mt Coot-tha this protocol achieved sub-metre repeatability: a mean separation of 0.6 m and a worst-case gap of 2.7 m between the best laps and the reference (see Field protocol).

Measuring agreement between two tracks

Three measures describe how closely two tracks follow each other. Both tracks are first resampled to the same spatial resolution, and each measure can be computed in 2D or in 3D (Sanchez et al., 2025b).

MeasureDefinitionReads as
Hausdorff distanceThe largest distance from a point of one track to the nearest point of the other, taken in both directionsWorst-case mismatch
SeparationThe median distance from the points of one track to the nearest point of the otherTypical mismatch
Metric ScoreThe share of points whose nearest point on the other track is within 1 mHow much of the track agrees at a human scale

The proposed targets for locomotion research are a Hausdorff distance under 3 m and a separation under 1 m (Sanchez et al., 2025b).

Placing a single track on the reference

With a reference in place, an individual activity on that trail no longer has to be taken at face value. Each reading is projected onto the reference, which tells where the athlete was along the trail at every second, with the elevation and slope of the reference rather than those of the device. This space-time localisation of single trajectories is what makes it possible to link movement on real terrain with physiological and biomechanical signals (Sanchez, 2025).

The metrictrails package offers three levels of this operation (Sanchez, 2026):

The reference framework was developed on a single 1 km loop under ideal satellite geometry, to favour repeatability. Extending it to longer trails in other environments, adding real-time kinematic (RTK) corrections and using raw GNSS data from smartwatches when manufacturers make it available are the next steps (Sanchez et al., 2025b; Sanchez, 2025).

The standard track

In short

Four stages turn any GPX file into a standard track: read it, sanitise the positions, resample to a uniform spatial resolution, and replace the elevation with values from a DEM. Only after this do distance and elevation gain become comparable between tracks.

  1. Raw GPX trackPositions, elevations and times as recorded or drawn.
  2. Sanitised trackImplausible readings flagged, noise reduced, drift corrected.
  3. Homogeneous trackPoints placed at a uniform horizontal spacing.
  4. Standard trackElevation from a common high-resolution DEM.

1. Read the file

read_stream() reads the track points of a GPX file (or its route points, for routes). Each recording segment is kept separate, so that later steps never join two points across a pause in the recording, and device extensions such as heart rate, cadence and temperature are kept as variables. uniform_stream() applies a common naming convention. Routes exported by planners often carry fake timestamps, all equal or one millisecond apart; when time increases in less than half of the readings, it is removed and the file is treated as a route without time (Sanchez, 2026).

2. Sanitise

sanitize_stream() first raises red flags on the raw readings: impossible coordinates, time that does not move forward, implausible speed, acceleration, slope or vertical speed, jumps at the start or end of the recording, elevation that changes while the athlete stands still, long gaps and sparse sampling. The flags and their thresholds are listed under GPX Audit. Flagged readings can be kept, dropped or replaced by interpolation (Sanchez, 2026).

It then smooths longitude and latitude, segment by segment, in metric coordinates. The default is a constant-velocity Kalman filter followed by a Rauch-Tung-Striebel smoother, which estimates the most likely path given the noise of the readings and the physics of a moving body. The alternatives are local regression (LOESS), a Gaussian kernel (Sánchez & Villena, 2020), a Savitzky-Golay filter, and the full post-processing sequence for running trajectories, with outlier detection and edge-jump correction (Martínez et al., 2026). Elevation is not smoothed by default, because it is replaced from a DEM at the end.

Sanitising before resampling matters. Resampling keeps fewer points than the original wherever readings are close together, and removing high-frequency noise first prevents that noise from being frozen into the resampled track.

3. Resample to a uniform spatial resolution

Because spatial resolution varies with speed (see Spatial resolution), the track is resampled along its horizontal path so that its points are evenly spaced. The result no longer depends on how fast the athlete moved or how often the device recorded. The package calls this step the "defractalizer" (Sanchez et al., 2025a; Sanchez et al., 2025b).

The spacing is chosen from the track itself. resolution_stream() looks at the horizontal distance between consecutive moving readings (stops of less than 0.1 m are ignored) and takes its 90th percentile. This is the Nyquist resolution of the track. With points every r metres, a uniform grid can represent features of the trail with a wavelength of at least 2r; at the 90th percentile, such features are resolved almost everywhere along the original track. A finer grid would invent points between sparse readings, and a coarser one would throw away information that was actually recorded (Sanchez, 2026).

To compare several tracks, all of them are resampled to one common spacing, at least as coarse as the coarsest of their Nyquist resolutions. Comparisons are always made by downsampling, never by inventing detail. fractal_stream() summarises how much a track gains in length when it is measured at finer scales as a fractal dimension, using the divider method: a straight line has a dimension of 1, and more complex paths have higher values (Mandelbrot, 1967; Sanchez et al., 2025a).

4. Elevation from a DEM

ele_correction() replaces the elevation of every point with the elevation of the ground at that location, interpolated bilinearly from a DEM (Sánchez & Villena, 2020). Without a local DEM, get_dem() downloads the open AWS Terrain Tiles along a corridor around the track, always at the finest zoom level (about 4 m at the latitude of Santiago, Chile, and 4.8 m at the equator) so that elevations are comparable everywhere. resample_dem() refines the DEM with bilinear interpolation, for example to 1 m, which brings elevation gain close to lidar accuracy (Sanchez et al., 2024a). Where a lidar DEM exists, it is the better source (Sanchez et al., 2025b).

What changes

The package's example activity, a trail run on Manquehue Hill in Santiago recorded with a GNSS watch, shows what the pipeline does to the headline numbers (Sanchez, 2026):

MeasureRaw device fileStandard track
Horizontal distance7,847 m7,281 m
Elevation gain889 m951 m
km-effort16.716.8
Mean spacing between points3.1 m6.2 m
Fractal dimension1.071.08

Distance falls because the zigzag added by drift is removed and the track is resampled at its Nyquist resolution of 6.3 m. Elevation gain rises because the device's elevation is replaced by the ground elevation from the DEM. Both numbers are now defined by a stated resolution and a stated elevation source, so they can be reproduced and compared with any other standard track at the same resolution.

Measures of a standard track

differential_stream() adds, for every reading, the horizontal and 3D distance from the previous reading, the change in elevation, slope, change of heading, speed, acceleration, pace and vertical speed. summarise_stream() gives course-level measures: 2D and 3D distance, elevation gain and loss, the mean and spread of slope, sinuosity, mean turning angle, km-effort, time spent stationary and the elevation gained or lost while stationary, and optionally the fractal dimension (Sanchez et al., 2025a; Sanchez et al., 2025b). tobler_stream() fits an asymmetric Tobler hiking function to the relation between speed and slope, at a high quantile of speed so that it describes the frontier of performance rather than the average (Tobler, 1993). Part IV shows how this was used to follow an athlete over five years.

MT standards

In short

Each MT standard is a spatial resolution: MT-1 (1 m), MT-5 (5 m) and MT-50 (50 m). A track is assigned the finest standard its own sampling supports, and it is also valid for the coarser ones.

StandardResolutionExpected useTypical source
MT-11 mScientific use, and the precision that elite competition and records requireHigh-end devices and field protocols with sub-metre sampling
MT-55 mCompetitive use: captures meaningful terrain detailGNSS recordings made in the field, which usually have an effective resolution of 2 to 4 m
MT-5050 mRecreational useRoutes drawn with route builders, typically 30 to 40 m between points

Why 1 m at the top

A spacing of 1 m captures the complexity of natural terrain at the scale of a human stride while keeping computation practical. Below 1 m, distance and elevation gain keep growing, but much more slowly than above it (Sanchez et al., 2025a). Field data agree: on Mt Coot-tha, track lengths were stable below the native spacing of about 1 m, and the variability of slope peaked at 1 to 2 m (Sanchez et al., 2025b).

How a level is set

The level is set on the original file, not on a processed version, from its Nyquist resolution: the 90th percentile of the horizontal distance between consecutive readings, ignoring stops. The file supports the finest standard whose resolution is at least as coarse as its Nyquist resolution:

The quality flags of the file describe its geometric, topographic and kinematic properties alongside the level. Files without timestamps are assessed on less evidence, because the checks that need time cannot run, but they are not excluded.

The 90th percentile is deliberately demanding. In the Manquehue example above, the sanitised track has a median spacing of 2.0 m, but 10% of its steps are longer than 6.3 m, where the runner moved fastest or the device recorded less often. Its Nyquist resolution is therefore 6.3 m, which supports MT-50 but not MT-5: in those parts of the run the file does not contain detail at 5 m (Sanchez, 2026).

A level can only go down after recording, never up. Lost resolution cannot be recovered, so the way to reach MT-5 or MT-1 is to record better, following a field protocol, not to process harder. To compare tracks at a standard, all of them are resampled to that standard's resolution and given elevation from the same DEM.

Working with the sport

Measurement standards only work when organisers, federations and certifying bodies adopt them; the challenge is organisational rather than technological (Sanchez et al., 2025a). Metric Trails is starting to work with federations, organisers and global initiatives, including Trail Running 2032, the International Trail Running Association (ITRA) and the Trail Running Association of Queensland (TRAQ), to implement this system together. The push for an international standard for measuring trail running events has been covered by ABC News (ABC News, 2025).

GPX Audit

In short

The GPX Audit checks a GPX file against the MT standards. It reports the file's quality flags, its spatial resolution and the MT level it supports. It does not correct or standardise the track.

The audit replicates, on the original file, the checks of read_stream(), uniform_stream(), sanitize_stream() and resolution_stream() from the metrictrails R package (version 1.0.0) with their default thresholds. Distances are horizontal and computed in the WGS 84 / UTM zone of the track. The computation runs in the browser; using the audit on this site requires a free account, and audited files and their reports are stored by Metric Trails for analysis and anonymised scientific use, as described in the privacy notice. The same audit can be run privately with the R package, which works on your own computer and sends nothing to Metric Trails.

What the flags mean

FlagRuleWhat it usually means
flag_coordMissing coordinate, latitude beyond 90°, longitude beyond 180°, or exactly (0, 0); these readings are removedCorrupted or empty readings
flag_timeTime does not increase from the previous readingDuplicated or out-of-order timestamps
flag_speedHorizontal speed from the previous reading above 10 m/sA position jump, not real movement
flag_accelAcceleration above 6 m/s² in absolute valueErratic positions
flag_jumpA step longer than 30 m among the first or last three readingsThe receiver had not settled when recording started or stopped
flag_slopeSlope steeper than 1.19 (about 50°) between moving readingsNoisy or rounded device elevation
flag_vert_speedVertical speed above 1 m/sElevation jumps
flag_idle_eleElevation changes while the horizontal position does not (less than 0.1 m)Barometric recalibration or drift during a stop; spurious elevation gain
flag_gapMore than 30 s between readings (information only)Pauses, signal loss or low sampling
flag_low_resMore than 20 m between readings (information only)Sparse sampling: routes drawn on a map, battery-saving modes or fast movement

The report also gives the share of elevations that are whole numbers (more than 90% indicates that the device rounds elevation to the metre), the elevation gained and lost while stationary, and the distribution of the spacing between readings: mean, standard deviation, quantiles, the Nyquist resolution and the resulting MT level.

When more than half of the readings imply speeds above 10 m/s, the timestamps are not physical, as in routes exported with fake times. The time-based checks are then skipped and the file is assessed as a route without time (Sanchez, 2026).

Audit a GPX file

The metrictrails package

In short

Every method in this wiki is implemented in metrictrails, an open-source R package published on CRAN under the MIT licence. It reads, cleans and standardises GNSS tracks from sports watches and similar devices, with a focus on trail and mountain running.

Install and run

install.packages("metrictrails")
library(metrictrails)

f   = system.file("extdata", "gpx_activity.gpx", package = "metrictrails")
dem = system.file("extdata", "test_dem.tif", package = "metrictrails")

raw = read_stream(f) %>% uniform_stream()

final = raw %>%
  sanitize_stream() %>%       # Kalman smoothing and red flags
  resample_stream() %>%       # Nyquist resolution
  ele_correction(dem = dem)   # DEM elevation (omit dem to download one)

summarise_stream(final, fractal = TRUE)

The vignette From a GPX file to research-grade trail measures walks through the full pipeline with the files shipped in the package. The source code is on GitHub, and citation("metrictrails") gives the reference to cite.

Functions

FunctionWhat it doesBased on
Pipeline
read_stream()Reads a GPX file (tracks or routes, segments and device extensions)
uniform_stream()Applies the naming convention: lon, lat, ele, timestamp, time
sanitize_stream()Red flags on raw readings; Kalman, LOESS, Gaussian, Savitzky-Golay or full post-processing smoothing(Sánchez & Villena, 2020; Martínez et al., 2026)
resolution_stream()Distribution of the spacing between readings and the Nyquist resolution(Sanchez et al., 2025a)
resample_stream()Resamples to a uniform spatial resolution (arc length or Douglas-Peucker)(Sanchez et al., 2025a; Sanchez et al., 2025b)
get_dem(), resample_dem()Downloads AWS Terrain Tiles along the track; refines or aggregates a DEM(Sanchez et al., 2024a)
ele_correction()Replaces elevation with values from a DEM(Sánchez & Villena, 2020)
Measures
differential_stream()Per-reading distance, elevation change, slope, heading change, speed, acceleration and pace(Sanchez et al., 2025b)
summarise_stream()Course-level measures, per track or per group(Sanchez et al., 2025a; Sanchez et al., 2025b)
fractal_stream()Fractal dimension of the path (divider method)(Mandelbrot, 1967; Sanchez et al., 2025a)
tobler_stream(), tobler_speed()Asymmetric Tobler hiking function fitted to a high quantile of speed(Tobler, 1993)
Two tracks
project_stream()Adds UTM coordinates, the projection used for every distance
locate_stream()Linear referencing: position along a reference and signed distance across it
compare_stream()Hausdorff distance, separation and Metric Score between two tracks(Sanchez et al., 2025b)
detect_stream()Passes of a track along a route, with direction and coverage
match_stream()Map matching to a known reference trail by dynamic programming(Sanchez, 2025)
write_stream()Writes a track to GPX

The package also ships two activities from the Strava API (a trail run on Manquehue Hill and a cross-country ride), a GPX activity with heart rate, cadence and temperature, the same loop drawn as a route, and a small DEM of the area.

References

  1. Mandelbrot, B. (1967). How long is the coast of Britain? Statistical self-similarity and fractional dimension. Science, 156(3775), 636-638. doi.org/10.1126/science.156.3775.636
  2. Martínez, C., Sanchez, R., & Diaz, C. (2026). A post-processing methodology for improving kinematic consistency in GNSS-based running trajectories. 6th International Conference on Electrical, Computer and Energy Technologies (ICECET), Rome. IEEE. doi.org/10.1109/ICECET65726.2026.11632531
  3. Sánchez, R., & Villena, M. (2020). Comparative evaluation of wearable devices for measuring elevation gain in mountain physical activities. Proceedings of the Institution of Mechanical Engineers, Part P: Journal of Sports Engineering and Technology, 234(4), 312-319. doi.org/10.1177/1754337120918975
  4. Sanchez, R., Egli, P., Besomi, M., & Truffello, R. (2024). Assessing the impact of digital elevation model resolution on elevation gain estimations in trail running. International Conference on Electrical, Computer and Energy Technologies (ICECET), Sydney. IEEE. doi.org/10.1109/ICECET61485.2024.10698606
  5. Sanchez, R., Egli, P. E., Jornet, K., Duggan, M., & Besomi, M. (2025). How fractal complexity distorts distance and elevation gain in trail and mountain running: the case for course measurement standardization. Proceedings of the Institution of Mechanical Engineers, Part P: Journal of Sports Engineering and Technology. Preprint: SportRxiv. doi.org/10.1177/17543371251341660
  6. Sanchez, R., Nieto-Jimenez, C., & Riveros-Matthey, C. (2025). High-precision mapping of mountain terrain for human locomotion research: a multimodal geospatial framework. 15th IEEE International Conference on Pattern Recognition Systems (ICPRS), Viña del Mar. doi.org/10.1109/ICPRS66293.2025.11302827
  7. Sanchez, R. (2025). Human trajectory mapping in ecological contexts: a framework for reliable space-time localization. ANZSCPB Conference 2025, Sippy Downs (abstract).
  8. Sanchez, R. (2026). metrictrails: Processing of GNSS streams from sports watches. R package version 1.0.0. CRAN.R-project.org/package=metrictrails
  9. Tobler, W. (1993). Three presentations on geographical analysis and modeling. National Center for Geographic Information and Analysis, Technical Report 93-1.
  10. Clarke, S. (2025, 28 May). Researcher pushing for international standard for mapping trail running events in bid for Olympics inclusion. ABC News. www.abc.net.au/news/2025-05-28/trail-running-international-standard-mapping-olympics-push/105308848