QGIS Track Editing
- QGIS is able to merge multiple line features into a single line, using Edit > Edit Geometry > Merge Selected Features.
- QGIS does not automatically close gaps when merging lines. Before merging, a third line needs to be created, snapped to the endpoints of the gap.
- The merge functionality provides a dialog allowing selection of which pre-merge feature each attribute should come from for the merged feature. Be careful to make sure the earliest utc_start and latest utc_stop are selected.
- If columns need to be reordered in the future, QGIS can do so with Processing > Toolbox > Vector table > Refactor fields.
LineString vs. MultiLineString
GPX files allow multiple disconnected track segments (trkseg) in the same track, effectively replicating the functionality of a MultiLineString. However, my entire process is set up already to split disconnected segments into their own tracks, so there’s little benefit to storing my track geometry as a MultiLineString, and my GeoPackage geometry is thus a LineString. (If in the future I did need to convert the driving log from a LineString geometry to a MultiLineString geometry, I could convert the layer in QGIS with Vector > Geometry Tools > Collect Geometries).
GeoPandas
- GPX and KML can relatively easily be converted to a GeoPandas GeoDataFrame, which can then be appended to a GeoPackage table using
GeoDataFrame.to_file(mode='a')
. - to_file uses Fiona, which requires columns to match when appending a GeoDataFrame to a layer. We have to be careful to ensure the import scripts and GeoPackage file use the same column structure at all times.
- We will need to define our columns and create a template file (stored within the gps_log_tools repository at templates/driving.template.gpkg). The import scripts can then check if a driving log GeoPackage file already exists, and copy it from the template if not.
- Appending to a layer within a file does not overwrite other layers. This means we could potentially store rental car data and other data in the GeoPackage as well.