### Install GPX Command-Line Tools with pip Source: https://github.com/tkrajina/gpxpy/blob/dev/README.md This snippet provides the command to install the `gpx-cmd-tools` package, which offers additional command-line utilities for working with GPX files. It uses the Python package installer, pip. ```bash pip install gpx-cmd-tools ``` -------------------------------- ### Run gpxpy Static Analysis and Unit Tests Source: https://github.com/tkrajina/gpxpy/blob/dev/README.md Command-line instruction to execute all static typing checks (mypy) and comprehensive unit tests for the gpxpy project, ensuring code quality and correctness. ```bash make mypy-and-tests ``` -------------------------------- ### gpxpy Core Object Model and Methods Source: https://github.com/tkrajina/gpxpy/blob/dev/README.md Documents key classes and methods within the gpxpy library, including the `GPXTrackPoint` constructor for creating points, `gpx.to_xml()` for serializing GPX objects to XML with optional version control, and `gpx.get_moving_data()` for calculating statistics with an option to retrieve raw data. ```APIDOC gpxpy.gpx.GPXTrackPoint: __init__(latitude: float, longitude: float, elevation: Optional[float] = None) latitude: The latitude of the track point. longitude: The longitude of the track point. elevation: Optional elevation of the track point. gpx.to_xml(version: Optional[str] = None) -> str: version: Optional GPX version to force for serialization (e.g., "1.0"). If None, the version is determined automatically. Returns: The GPX object serialized as an XML string. gpx.get_moving_data(raw: bool = False) -> Any: raw: If True, calculates raw max speed and other moving data without applying heuristics to remove common GPS errors. Returns: An object containing moving data statistics (e.g., max_speed). ``` -------------------------------- ### Run Specific gpxpy Unit Test Source: https://github.com/tkrajina/gpxpy/blob/dev/README.md Command-line instruction to execute a single, specified unit test within the gpxpy test suite, useful for debugging or focused testing. ```bash python3 -m unittest test.GPXTests.test_haversine_and_nonhaversine ``` -------------------------------- ### Create New GPX File with gpxpy Source: https://github.com/tkrajina/gpxpy/blob/dev/README.md Illustrates how to programmatically construct a new GPX object from scratch using gpxpy. It demonstrates adding a track, a segment within that track, and then appending multiple GPXTrackPoint objects with specified latitude, longitude, and elevation. The created GPX object is then converted to its XML representation. ```python import gpxpy import gpxpy.gpx # Creating a new file: # -------------------- gpx = gpxpy.gpx.GPX() # Create first track in our GPX: gpx_track = gpxpy.gpx.GPXTrack() gpx.tracks.append(gpx_track) # Create first segment in our GPX track: gpx_segment = gpxpy.gpx.GPXTrackSegment() gpx_track.segments.append(gpx_segment) # Create points: gpx_segment.points.append(gpxpy.gpx.GPXTrackPoint(2.1234, 5.1234, elevation=1234)) gpx_segment.points.append(gpxpy.gpx.GPXTrackPoint(2.1235, 5.1235, elevation=1235)) gpx_segment.points.append(gpxpy.gpx.GPXTrackPoint(2.1236, 5.1236, elevation=1236)) # You can add routes and waypoints, too... print('Created GPX:', gpx.to_xml()) ``` -------------------------------- ### Parse Existing GPX File with gpxpy Source: https://github.com/tkrajina/gpxpy/blob/dev/README.md Demonstrates how to open and parse an existing GPX file using gpxpy. It then iterates through tracks, segments, points, waypoints, and routes to access their data, such as latitude, longitude, and elevation. Finally, it shows how to convert the parsed GPX object back into an XML string. ```python import gpxpy import gpxpy.gpx # Parsing an existing file: # ------------------------- gpx_file = open('test_files/cerknicko-jezero.gpx', 'r') gpx = gpxpy.parse(gpx_file) for track in gpx.tracks: for segment in track.segments: for point in segment.points: print(f'Point at ({point.latitude},{point.longitude}) -> {point.elevation}') for waypoint in gpx.waypoints: print(f'waypoint {waypoint.name} -> ({waypoint.latitude},{waypoint.longitude})') for route in gpx.routes: print('Route:') for point in route.points: print(f'Point at ({point.latitude},{point.longitude}) -> {point.elevtion}') # There are many more utility methods and functions: # You can manipulate/add/remove tracks, segments, points, waypoints and # routes and get the GPX XML file from the resulting object: print('GPX:', gpx.to_xml()) ``` -------------------------------- ### GPX File Format Schema Definition Source: https://github.com/tkrajina/gpxpy/blob/dev/xsd/gpx1.0.txt Defines the complete structure of a GPX file, including its root element 'gpx' and nested elements like 'wpt' (waypoint), 'rte' (route), and 'trk' (track). Each element's attributes and child elements are listed, along with their types and requirements. ```APIDOC gpx - attr: version (xsd:string) required - attr: creator (xsd:string) required name desc author email url urlname time keywords bounds wpt - attr: lat (gpx:latitudeType) required - attr: lon (gpx:longitudeType) required ele time magvar geoidheight name cmt desc src url urlname sym type fix sat hdop vdop pdop ageofdgpsdata dgpsid rte name cmt desc src url urlname number rtept - attr: lat (gpx:latitudeType) required - attr: lon (gpx:longitudeType) required ele time magvar geoidheight name cmt desc src url urlname sym type fix sat hdop vdop pdop ageofdgpsdata dgpsid trk name cmt desc src url urlname number trkseg trkpt - attr: lat (gpx:latitudeType) required - attr: lon (gpx:longitudeType) required ele time course speed magvar geoidheight name cmt desc src url urlname sym type fix sat hdop vdop pdop ageofdgpsdata dgpsid ``` -------------------------------- ### GPX File Format Schema Definition Source: https://github.com/tkrajina/gpxpy/blob/dev/xsd/gpx1.1.txt Defines the hierarchical structure and data types for GPX (GPS Exchange Format) files, including metadata, waypoints, routes, and tracks. Each element and its attributes are listed with their corresponding XML Schema Definition (XSD) types. ```APIDOC gpx (gpxType) - attr: version (xsd:string) None - attr: creator (xsd:string) None metadata (metadataType) name (xsd:string) desc (xsd:string) author (personType) name (xsd:string) email (emailType) - attr: id (xsd:string) None - attr: domain (xsd:string) None link (linkType) - attr: href (xsd:anyURI) None text (xsd:string) type (xsd:string) copyright (copyrightType) - attr: author (xsd:string) None year (xsd:gYear) license (xsd:anyURI) link (linkType) - attr: href (xsd:anyURI) None text (xsd:string) type (xsd:string) time (xsd:dateTime) keywords (xsd:string) bounds (boundsType) - attr: minlat (latitudeType) None - attr: minlon (longitudeType) None - attr: maxlat (latitudeType) None - attr: maxlon (longitudeType) None extensions (extensionsType) wpt (wptType) - attr: lat (latitudeType) None - attr: lon (longitudeType) None ele (xsd:decimal) time (xsd:dateTime) magvar (degreesType) geoidheight (xsd:decimal) name (xsd:string) cmt (xsd:string) desc (xsd:string) src (xsd:string) link (linkType) - attr: href (xsd:anyURI) None text (xsd:string) type (xsd:string) sym (xsd:string) type (xsd:string) fix (fixType) sat (xsd:nonNegativeInteger) hdop (xsd:decimal) vdop (xsd:decimal) pdop (xsd:decimal) ageofdgpsdata (xsd:decimal) dgpsid (dgpsStationType) extensions (extensionsType) rte (rteType) name (xsd:string) cmt (xsd:string) desc (xsd:string) src (xsd:string) link (linkType) - attr: href (xsd:anyURI) None text (xsd:string) type (xsd:string) number (xsd:nonNegativeInteger) type (xsd:string) extensions (extensionsType) rtept (wptType) - attr: lat (latitudeType) None - attr: lon (longitudeType) None ele (xsd:decimal) time (xsd:dateTime) magvar (degreesType) geoidheight (xsd:decimal) name (xsd:string) cmt (xsd:string) desc (xsd:string) src (xsd:string) link (linkType) - attr: href (xsd:anyURI) None text (xsd:string) type (xsd:string) sym (xsd:string) type (xsd:string) fix (fixType) sat (xsd:nonNegativeInteger) hdop (xsd:decimal) vdop (xsd:decimal) pdop (xsd:decimal) ageofdgpsdata (xsd:decimal) dgpsid (dgpsStationType) extensions (extensionsType) trk (trkType) name (xsd:string) cmt (xsd:string) desc (xsd:string) src (xsd:string) link (linkType) - attr: href (xsd:anyURI) None text (xsd:string) type (xsd:string) number (xsd:nonNegativeInteger) type (xsd:string) extensions (extensionsType) trkseg (trksegType) trkpt (wptType) - attr: lat (latitudeType) None - attr: lon (longitudeType) None ele (xsd:decimal) time (xsd:dateTime) magvar (degreesType) geoidheight (xsd:decimal) name (xsd:string) cmt (xsd:string) desc (xsd:string) src (xsd:string) link (linkType) - attr: href (xsd:anyURI) None text (xsd:string) type (xsd:string) sym (xsd:string) type (xsd:string) fix (fixType) sat (xsd:nonNegativeInteger) hdop (xsd:decimal) vdop (xsd:decimal) pdop (xsd:decimal) ageofdgpsdata (xsd:decimal) dgpsid (dgpsStationType) extensions (extensionsType) extensions (extensionsType) extensions (extensionsType) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.