3

I am trying to generalise a line in QGIS so that I can export it as a vector without it having an unnecessarily huge file size. The line shows the GPS track of a road trip, and as such varies between having straight lines connecting a few points over a relatively large distance (eg where I was driving at 75mph along a straight road) and many points very close to each other (ie where I've stayed in the same building, but the GPS has wandered slightly and linked up several points close to each other).

The images below show the output from the Vector --> Geometry Tools --> Simplify tool (with a basemap for scale context): the original GPS track is red and the simplified version is black. As you can see, although the tool straightens out journeys of hundreds of km (more than I would want it to), if you zoom into the places where points have been more densely recorded (ie where I've stayed in the same place for an extended period of time), much of the unwanted noise is still there (albeit simplified).

generalised map 1

generalised map 2

Is there a tool for QGIS that will generalise in a way that doesn't simply remove a certain number of vertices without consideration of the distance between them, but will remove the noise of the type seen in the second screenshot? I am ultimately looking to map the whole route (~5,000 miles), so don't need to see where within a particular town I walked, but would like to still preserve the routes driven along roads (ie the red in the first image) to a reasonable degree.

I have tried various menu option configurations and an additional generalisation plugin, but all have yielded similar results.

  • 1
    Have you tried line smoothing? – Erik Dec 2 at 17:05
  • @Erik I've tried using the Cartographic Line Generalisation plugin, but the results just seem to have smoothed out the corners for the most part but haven't removed the noise itself. Maybe I need to fiddle with the options more for a better result. – Matthew Law Dec 2 at 17:24
4

It might help to add vertices to the long segments without vertices. It seems counterintuitive, but I think you'll get better results from the simplification tool when the vertices of the input line are spaced at approximately equal distances. Estimate the average distance between vertices in the very dense areas. Then use that distance in the densify by interval tool.

2

You could give GPSBabel a try:

gpsbabel -i gpx -f track_after.gpx -x simplify,count=400 -o gpx -F simplified_track.gpx

The 400 points is just an example, you will have to trial-and-error, or count you track points and make an educated guess how much percent of points will still be enough.

Online manual: https://www.gpsbabel.org/htmldoc-1.6.0/filter_simplify.html (not very descriptive)

GPSBabel should be somewhere in reach with your QGIS-Installation, at least it is available through the OSGEO4W-Installer (advanced mode, I think, am on Linux)

Didn't use it recently, but long time ago quite successfully.

  • Thanks for the suggestion – I've attempted this, but when I specified 500 points (converting from .shp to .shp and simplifying), the output .shp was only 100 bytes (and obviously showed nothing in QGIS), so I suspect either it or I am doing something wrong. – Matthew Law Dec 2 at 17:39
  • did you check how many points you layer has? I think there are even more than 500 vertices within the knot in the second image. I wrote "educated" guess ! ;) I have no idea that working with shape is supported, it's a GPS-tool for all kind of formats ... Explode your line to points, check how many you have, and then work percent-wise from 75 to 50 to whatever. – Bernd V. Dec 2 at 18:34
0

In Processing search for v.generalize where you have a lot's of algorithms

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.