Preserve GPX Track Segments When Converting Drone Survey Records
Inspect GPX track and segment structure, retain segment identities and point order, and avoid inventing continuous survey paths across recorded gaps.

Establish the role of the GPX file
A line drawn through every recorded position can appear to show an uninterrupted drone mission even when the source contains separate track segments. Before converting a GPX file for a NiVO survey review, determine whether it is an original recorder export, a filtered derivative or a manually prepared reference. Preserve that distinction throughout the handover. This tutorial inspects a known local GPX 1.1 file and the representation of its track boundaries. It does not use an actual mission, reconstruct missing movement or claim that a particular aircraft exports GPX directly.
Record the source filename, byte digest, exporter and intended use. A GPX track can provide useful location context, but it is not interchangeable with a complete flight-controller log or a camera event record. Define whether the recipient needs a visual overview, per-point attributes or an ordered line suitable for a particular analysis. Keep the original file unchanged and use a working copy for inspection. If the export history is unknown, retain that limitation rather than allowing a smooth line in the GIS to become evidence that every part of the displayed path was observed.
Read tracks and segments as separate levels
The GPX 1.1 schema defines a track as an ordered path represented through track segments. A segment holds track points that are logically connected in order. The schema documentation specifically describes starting a new segment for a continuous span after a reception loss or receiver shutdown. This makes the boundary meaningful information to preserve. It does not establish the cause of every boundary in every export: an application may have processed or split the source. Use recording history to interpret why a segment changed instead of assigning a cause solely from the XML structure.
Distinguish tracks, track segments and track points in the inventory. Several tracks need not represent consecutive portions of one mission, and a waypoint or planned route is not automatically a recorded track. Within a segment, retain the original point sequence before considering a derived ordering. Repeated or missing timestamps require review; sorting the entire file by time can move points across source boundaries or mix separate tracks. A conversion should preserve the source organization first, then make any deliberate merging or reordering explicit as a new representation with its own limited purpose.

Product context only; this photograph does not depict the constructed examples in this article.
Inspect the segment inventory explicitly
The following Python example reads a trusted local GPX 1.1 working copy and prints the track number, segment number and number of points in each segment. Its namespace mapping matters: the schema namespace is part of the XML element name, so a search that ignores it can return an empty result even when visible track points exist. Replace track.gpx with the identified input. The example loads the document into memory and is intended for a manageable inspection file, not a claim of bounded-memory processing for every possible archive size.
Confirm that the file uses the expected namespace before interpreting the output. An empty listing can mean a different GPX version, a file containing routes rather than tracks, or a selection problem. The code counts structural elements only. It does not validate the full schema, check coordinate plausibility, inspect timestamp order or certify recording completeness. Python's XML documentation also distinguishes trusted input from untrusted-data parsing requirements; use the project's approved handling for unfamiliar files. No real track was parsed for this article and no successful point or segment total is invented.
import xml.etree.ElementTree as ET
uri = ("http://www.topografix.com/"
"GPX/1/1")
ns = {"g": uri}
root = ET.parse("track.gpx").getroot()
if root.tag != "{" + uri + "}gpx":
raise ValueError("Expected GPX 1.1")
tracks = root.findall("g:trk", ns)
for tn, track in enumerate(tracks, 1):
segments = track.findall("g:trkseg", ns)
for sn, seg in enumerate(segments, 1):
points = seg.findall("g:trkpt", ns)
print(tn, sn, len(points))Retain segment keys in the GIS conversion
GDAL documents GPX tracks as a MultiLineString layer and also exposes individual points through a track_points layer. The point representation includes track and segment identifiers plus the sequence within a segment. Inspect the fields actually produced by the installed driver and preserve the relevant keys when creating a derivative. Do not group all points under one flight label and then build a single line without the segment key. That operation can insert connectors between the end of one recorded span and the beginning of the next, even though those connecting positions were not supplied.
Check geometry-part and point counts independently after conversion. Open the result in the intended application and examine a known segment boundary, not only a convenient continuous section. If separate segments are represented as parts of one feature, verify that the recipient preserves those parts. If an application requires one feature per segment, create that representation deliberately and retain a link to the original track and segment identity. Counts alone cannot prove that order and boundaries survived, so compare representative endpoint coordinates and point order against the source inspection record.
Keep gaps visible in derived analysis
A connector across a gap can affect length, apparent speed or the visual relationship between the track and a survey block. Decide which calculations are supported by the source before reporting them. A straight chord between two recorded endpoints is a constructed geometric connection, not evidence of the path flown during an unobserved interval. If a display needs a connector for orientation, distinguish it visually and label its role. Keep it outside the accepted observed-track geometry used for calculations that depend on actual continuity, rather than silently including it in an overall line length.
Within each retained segment, position spacing and timestamps still deserve review. A segment boundary is useful structure, not a guarantee that every interval inside the segment meets a sampling or quality requirement. Explain any interpolation, simplification or removal of repeated points and retain the source representation. Do not infer image coverage from the track alone. Payload state, acquisition timing, view direction and actual stored observations need their own evidence. This preserves the value of the GPX overview without promoting a convenient derivative into a substitute for the records required by the survey question.
Make the handover continuity-aware
Deliver the original GPX identity, structural inventory, conversion settings and the resulting track representation together. Explain how tracks and segments map to features or geometry parts in the recipient application. Retain point-order keys where they are needed for repeatable processing. Include a checked example boundary in the opening notes so another analyst can verify the same distinction after copying the package. If a later revision combines segments for a different presentation purpose, identify that output separately and describe its constructed connectors instead of replacing the evidence-preserving version without explanation.
For a NiVO data review, the useful conclusion is precise: the derivative retains the observed track spans and identifies the intervals that the supplied record does not connect. It does not declare the reason for every gap, prove continuous navigation or establish capture completeness. Review those questions using the relevant original logs and payload records. A small amount of structural checking before line conversion prevents a visually persuasive but unsupported path from entering reports, measurements or mission comparisons, while giving recipients a clear and repeatable way to inspect what the GPX file actually represents.



