On our aerial wildlife surveys we typically generate dozens of GPX files, and usually convert most of them into shapefiles for display in a GIS application. GPX files are a terrific way of keeping all (or almost all) of your GPS data in one place – they are xml files that store tracklog, waypoint & route information in one convenient format. They store multiple tracks, even old saved tracks from a Garmin.
I'd like to store all this track data in a spatialite database, in parallel with other tables that have point observational data from the same survey.
ogr2ogr will let me convert the track to a spatialite database:
ogr2ogr -append -f "SQLite" -dsco SPATIALITE=yes # add to table with Spatialite filetype -dsco INIT_WITH_EPSG=yes -t_srs epsg:4326 # using WGS84 SURVEYDATA.sqlite GPXFILE.gpx tracks -nln tracktable; # adding tracks to 'tracktable'
However, this imports each saved track as a line – losing the time / location information for each track point!
Anyone know of any clever ways of building a tracklog database that will preserve that information?
Tracklogs are not just a line - they are collections of sequential points, each with an elevation and time attribute. Each point belongs to a track segment, which in turn belong to a given track, and points within each track segment were taken without interruption and may be assumed to be linked. For example:
<trk><name>ACTIVE LOG</name> <trkseg> <trkpt lat="-13.471403" lon="31.382982"><ele>467.818725585938</ele><time>2009-09-09T03:53:38Z</time></trkpt> <trkpt lat="-13.471403" lon="31.382982"><ele>468.780029296875</ele><time>2009-09-09T03:53:50Z</time></trkpt> <trkpt lat="-13.471403" lon="31.382982"><ele>465.896118164063</ele><time>2009-09-09T03:54:43Z</time></trkpt> </trkseg>
Thus, to save a tracklog you need to save this collection of points with their associated data.
One solution might be to load these tracks as points, with additional columns for track name, segment, elevation and time; I don't think ogr will convert the tracks as points, though.