TransWikia.com

Performing Spline interpolation on GPS Track

Geographic Information Systems Asked by Benzo on March 22, 2021

I’m looking for a way to apply spline interpolation to a gps track (GPX format). I am a regular QGIS user and also have GDAL libraries installed on my Mac if that helps.

Basically trail and ride information on MTB Project has a small set of points and actual paths are expanded via spline interpolation to reduce file sizes. I can download the tracks in gpx format, but they only contain a small set of points, giving me a track which resembles a jagged line which represents the small amount of points before interpolation. I want to apply a similar transformation to re-create the curved lines that are on the website, in a somewhat repeatable process that doesn’t have me manually re-tracing each point with the spline drawing tool in QGIS.

enter image description here

Does anyone know of a way that I can easily apply spline interpolation to my gps track data to reproduce the splined track from MTB Project using free tools? Preferably on OSX?

3 Answers

Try using v.generalize tool from the Processing Toolbox. There are a number of algorithms in there that can generalize a line nicely.

Another possible solution could be the "Generalizer" plugin which was mentioned in this post, the plugin info in QGIS suggests that the tool is based on the v.generalizer Grass module anyway.

Just for reference below is an example of the output from the v.generalize tool. I used the default inputs for both the Chaiken and Hermite outputs, I have no doubt you could receive better results with a bit of research into the tool and specifically what the input values mean.

Update - The Snakes algorithm (not show in the orginal image below) with some tweaking of the alpha and beta parameters gives a smoother appearance on my test dataset.

Example of v.generalize output


References:

Answered by Andrew Jeffrey on March 22, 2021

I feel awkward, but let me recommend QGIS + Spline Plugin as one of the options for your case.

  1. Yes, digitizing all points is cumbersome. But setting an appropriate Snap Option parameter can lessen a burden of the task.
  2. Other software capable to create Splines would be CAD (e.g. AutoCAD) or mathematical solution (e.g. R). If you choose CAD, its workflow is almost same, to repeat clicking points to add spline segments.
  3. If the bicycle track was an "ideal" spline curve, mathematically interpolated, best fit spline will be the solution. In reality, such spline rarely represents whole your track. You may end up splicing several curves, by attempting various smoothing parameters.
  4. When you use Spline Plugin, you can change parameters as you progress digitizing.

enter image description here

If your Tightness is set to 0.5 (default value), it can connect dense measurement points smoothly, and higher Tightness tries not to bend the curve at around those points.

You will notice Blue curve (0.9) fits better at gentle curve, and Orange (0.5) is good for tight corners. This flexibility is the best part of manually digitizing by Spline Plugin. If we try to do it by math equation, it can be nightmare.

  1. I am afraid generalize technique does not honor original data points. In other words, curve derived by generalizer does not go through your bicycle track.

Answered by Kazuhito on March 22, 2021

There is a python script "gpx_interpolate" on Github which will do interpolation between GPX track points.

python3 gpx_interpolate.py -r 50 -d 3 INPUT.gpx

This will output a new file INPUT_interpolated.gpx with 50m (-r 50) between points and along spline of degree 3 (-d 3).

Options:

  • Resolution -r: distance between interpolated points. Default is 1m (change this if you have a long tracklog or you'll end up with a long wait and huge output file);
  • Degree -d: polynomial degree starting from 1 (straight lines) then up to degree 5 (2-5 all curves).
  • Number of points -n: force a certain number of output points (default is 0, no limit).

enter image description here

I've been using this to produce better estimates of actual tracks from aircraft flight logs where the GPS was set to a 10-second interval. In the example above setting resolution r to 50 interpolated an approximately 1-second interval which matches closely the real track. This is really helpful when using a low-res GPS track to correctly georeference images taken in flight.

Note that this script doesn't preserve the original trackpoints, but it is possible to merge the originals with the new interpolation using gpsbabel:

gpsbabel -i gpx -f INPUT.gpx -f INPUT_interpolated.gpx -x track,merge -o gpx -F INPUT_merged.gpx

Answered by Simbamangu on March 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP