https://github.com/bernhardangerer/gpx-stats-helper
The "GPX stats helper" library allows reading from GPX files (GPS data) and calculates a lot of helpful parameters
https://github.com/bernhardangerer/gpx-stats-helper
geocoding gps-data gpx gpx-library gpx-reader java java-11 openstreetmap reverse-geocoding statistics
Last synced: 6 months ago
JSON representation
The "GPX stats helper" library allows reading from GPX files (GPS data) and calculates a lot of helpful parameters
- Host: GitHub
- URL: https://github.com/bernhardangerer/gpx-stats-helper
- Owner: BernhardAngerer
- License: gpl-3.0
- Created: 2023-05-19T14:37:34.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-15T16:57:51.000Z (over 1 year ago)
- Last Synced: 2025-03-15T17:33:56.124Z (over 1 year ago)
- Topics: geocoding, gps-data, gpx, gpx-library, gpx-reader, java, java-11, openstreetmap, reverse-geocoding, statistics
- Language: Java
- Homepage:
- Size: 332 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://github.com/BernhardAngerer/gpx-stats-helper/actions/workflows/maven-publish.yml)
[](https://github.com/BernhardAngerer/gpx-stats-helper/actions/workflows/maven-verify.yml)
# π°οΈ GPX Stats Helper Library
A lightweight Java library for **reading, manipulating, writing, and analyzing statistics** from GPX 1.1 files using the official [TopoGrafix XSD schema](https://www.topografix.com/gpx.asp).
This library enables developers to:
- Parse and generate GPX 1.1-compliant files
- Integrate with external APIs for reverse geocoding (OpenStreetMap/Nominatim)
- Calculate key track statistics (distance, elevation, duration, speed, slope, etc.)
## π Track Statistics Calculated
### π§ General Track Info
- Number of waypoints
### π Distance & Elevation
- Total / ascent / flat / descent distance `[m]`
- Ascent / descent elevation `[m]`
- Lowest / highest point `[m]`
- Slope between two waypoints as percentage `%`
- Slope distribution summary: percentage range β distance `[%, m]`
### β±οΈ Time & Duration
- Total duration `[h]`
- Duration in motion / at rest `[h]`
- Start / end time `[h]`
### π΄ Speed & Movement
- Max / average speed `[km/h]`
- Total / In Motion average pace `[min/km]`
### πΊοΈ Geographic Extents
- Latitude range `[lat, lat]`
- Longitude range `[lon, lon]`
### π Geopositions
- Start / end / farthest position `[lon, lat, m]`
- Positive and negative elevation peak positions `[lon, lat, m]`
### π Coordinate Format Conversion
- Convert decimal degrees to Degrees Minutes Seconds (DMS) format
### π£οΈ Geolocation Metadata
- Description of any geo-position
*(using the free [Nominatim API](https://nominatim.org/release-docs/develop/api/Reverse/) for reverse geocoding based on OpenStreetMap data)*
## β
Requirements
+ Java 17+
+ Maven
## π Examples
### π₯ Read GPX object from file
```java
GpxReader.fromFile("example/example1.gpx").getTrk().stream()
.flatMap(track -> track.getTrkseg().stream())
.flatMap(trackSegment -> trackSegment.getTrkpt().stream())
.forEach(waypoint -> System.out.println(formatWaypoint(waypoint)));
```
### πΎ Write GPX object to file
```java
Gpx gpx = new Gpx();
Track track = new Track();
TrackSegment segment = new TrackSegment();
segment.getTrkpt().addAll(List.of(
createWaypoint(47.80743, 12.378228, 587, LocalDateTime.of(2025, 4, 7, 16, 14, 16)),
createWaypoint(47.807343, 12.378138, 588, LocalDateTime.of(2025, 4, 7, 16, 14, 17))
));
track.getTrkseg().add(segment);
gpx.getTrk().add(track);
File file = GpxWriter.toFile(gpx, "output/generatedFile.gpx");
```
### π§Ύ Example Output (`example.gpx`)
> Generated by running `Example.main()`
```
ποΈ Metadata
Name: "My sport activities"
Author Name: "Bernhard Angerer"
Copyright Year: "2022"
Copyright Author: "Bernhard Angerer"
Link Href: "https://github.com/BernhardAngerer"
### Track Nr. 1 - "Mountainbike-Tour to the Kampenwand/Germany" ###
π§ General Track Info
Number Of Waypoints: 2108
π Distance & Elevation
Distance (Total): 26,42 km
Distance (Ascent): 9,56 km
Distance (Flat): 7,78 km
Distance (Descent): 9,07 km
Distance (Unknown Elevation): 0 km
Elevation (Ascent): 1008 m
Elevation (Descent): 997 m
Highest Point: 1547 m.s.l.
Lowest Point: 587 m.s.l.
Slope between start and end point: 69 %
Slope 20 to 30 % -> 0,02 km
Slope 10 to 20 % -> 2,03 km
Slope 0 to 10 % -> 15,3 km
Slope -10 to 0 % -> 5 km
Slope -20 to -10 % -> 3,66 km
Slope -30 to -20 % -> 0,41 km
πΊοΈ Geographic Extents
Latitude Range: 47.754356 => 47.80743
Longitude Range: 12.334281 => 12.378897
β±οΈ Time & Duration
Duration (Total): 02:36:34 h
Duration (Motion): 02:15:36 h
Duration (Rest): 00:20:58 h
Start Time: 07.09.2021, 15:37:42 h
End Time: 07.09.2021, 18:14:16 h
π΄ Speed & Movement
Speed (Maximum): 51,9 km/h
Speed (Average): 11,7 km/h
Pace Average (Total): 05:56 min/km
Pace Average (Motion): 05:08 min/km
π Geopositions
Start Position: Lat 47.80743, Lon 12.378228, Ele 587
End Position: Lat 47.807346, Lon 12.378055, Ele 598
Farthest Point: Lat 47.754356, Lon 12.355104, Ele 1546
Positive Peak 1: Lat 47.754635, Lon 12.355498, Ele 1547
Negative Peak 1: Lat 47.80743, Lon 12.378228, Ele 587
Negative Peak 2: Lat 47.807049, Lon 12.378118, Ele 598
π Coordinate Format Conversion
Lat 47.80743, Lon 12.378228 -> 47Β°48'26.748"N, 12Β°22'41.621"E
π£οΈ Geolocation Metadata
Start = End - Geoposition: LindenstraΓe, Bergham, Kraimoos, Bernau am Chiemsee, Landkreis Rosenheim, Bayern, 83233, Deutschland
Start = End - Geoposition URL: https://nominatim.openstreetmap.org/ui/reverse.html?lat=47.80743&lon=12.378228&zoom=18&layer=poi
### Track Nr. 2 - "Mountainbike-Tour in the Karwendel-Mountains from Scharnitz to Radfeld" ###
...
```
## π¦ Dependency (Maven / Gradle)
Add the dependency via https://jitpack.io/private#BernhardAngerer/gpx-stats-helper/4.0.0