Simple parser for loading basic information about track points from .gpx files.
Inside the gpx tag parser only extracts trk, trkseg, and trkpt tags.
All other tags are ignored.
Resulting GPX structure is a container with track list. Each track is in it's turn a list of segments, and segment is
a list of track points, the leaf elements of the structure.
GPX, GPXTrack, an GPXTrackSegment support most of the list methods.
### Prerequisites
Python 3.4 or higher
xml or lxml
### Examples of usage
```python
import gpx_parser as parser
with open('file_name', 'r') as gpx_file:
gpx = parser.parse(gpx_file)
print("{} tracks loaded".format(len(gpx)))
```
```
for track in gpx:
print('Track with {} segments and {} points'.
format(len(track), track.get_points_no()))
for segment in track:
print('Segment with %s points % len(segment))
for point in segment:
print(point)
```
##### GPX
```
gpx.tracks # list of tracks
gpx.version # str or None
gpx.creator # str or None
gpx.points # list of all points from all tracks
len(gpx)) # number of tracks in gpx
gpx.get_points_no() # total number of points in all segments of all tracks
gpx[0] # 0th track, same as gpx.tracks[0]
gpx[1:3] # = gpx.tracks[1:3]
gpx.contains(track) # = gpx.tracks.contains(track)
gpx.append(track) # = gpx.tracks.append(track)
gpx.extend(tracks) # = gpx.tracks.extend(tracks)
gpx.remove(track) # = gpx.tracks.remove(tracks)
gpx.clone() # returns deepcoopy of the object
gpx.to_xml() # str, point with xml tags
gpx.length_2d() # total 2d distance of the track
gpx.get_bounds() # min and max latitude and logitude
gpx.get_time_bounds() # start and end time
gpx.walk() # generator, yields (point, track_num, segment_num, point_num)
```
##### GPXTrack
```
track.name # str or None
track.number # int or None
track.segments # list of all segments in the track
track.points # list of all points from all segments
len(track) # number of segments in the track
track[0] #
track[::2] # shorcuts for
track.contains(segment) # track.segments
track.append(segment) #
track.extend(segmengs) #
track.remove(segment) #
track.to_xml() #
track.length_2d() # same as for gpx
track.get_bounds() #
track.get_time_bounds() #
track.get_points_no() #
track.clone() #
track.get_duration() # float, duration of track in seconds
track.remove_empty() # removes empty segments from the track
```
##### GPXTrackSegment
```
seg.points # list of points in the segment
len(seg) #
seg[0] #
seg[::2] # shortcuts for
seg.contains(segment) # seg.points
seg.append(segment) #
seg.extend(segmengs) #
seg.remove(segment) #
seg.to_xml() #
seg.length_2d() # same as for gpx
seg.get_bounds() #
seg.get_time_bounds() #
seg.get_points_no() #
seg.clone() #
seg.get_duration() # float, duration of track in seconds
seg.remove_empty() # removes empty segments from the track
```
##### GPXTrackPoint
```
point.latitude
point.longitude
point.time
point.to_xml()
point.distance_2d(other_point) # distance in meters
point.time_difference(other_point) # time in seconds, or None, if one of the points doesn't have time attribute.
point.speed_between(other_point) # speed, i m/s, or None, if one of the points doesn't have time attribute.
```
Metadata
Release files for gpx-parser 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| gpx-parser-0.0.4.tar.gz | 8.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gpx_parser-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.5 kB
Release files / gpx-parser-0.0.4.tar.gz
| Download URL | gpx-parser-0.0.4.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b99884df696cc86a21b92ad87994a21bfb890734680c3db4ce152571e23f0bc
|
|
BLAKE2b-256 checksum How to use checksums |
ff38f7c21cf5af886a2ede4ee197e5b50fec1829e7f71fcb4cfb23705b85268f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / gpx_parser-0.0.4-py3-none-any.whl
| Download URL | gpx_parser-0.0.4-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba13e23a0cd023a4d14163b7a4d18d7db10942588402b138633b9f20a0eee4ca
|
|
BLAKE2b-256 checksum How to use checksums |
83f0673a1a587bdc95c8cffa129fecfb441a99bca97ceb91e53f80787e7ad308
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for gpx-parser 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.