36

I am moving from creating maps with Illustrator to making them with QGIS and actual data. One of the things I haven't been able to re-create in QGIS are the smooth curved lines I can get in Illustrator. I am not talking about Join and Cap Styles, but how an entire line is rendered.

I am looking for an answer that doesn't include exporting as SVG to Illustrator and finishing the map there.

Also, I realize they could be considered an inaccurate representation but, for the most part, these maps are for giving riders an idea of where they are and don't necessarily have to be an exact representation.

Here is an example of what I mean: enter image description here

1
  • 2
    How is your data stored? Most data formats (e.g. shapefile) do not allow for arcs. I beleive some databases now do though. Commented Jan 12, 2012 at 20:04

5 Answers 5

24

Check out the Generalizer plugin, it should do what you want. The plugin has smoothing options which work quite well.

It doesn't change how your lines are rendered but instead makes a new shapefile with smoothing (or simplification/generalization) applied.

enter image description here

enter image description here

7
  • I can't find this plugin for QGIS 1.7.3 even though I have 3rd party repos enabled. Can you show how to enable/find it? Looks interesting and straightforward.
    – SaultDon
    Commented Jan 12, 2012 at 21:54
  • 3
    Strange. It should be in the plugin installer as it's coming from the main QGIS plugin repo.
    – Nathan W
    Commented Jan 12, 2012 at 22:02
  • 3
    You're right, but from the Python Plugin Installer I had to go to the options tab and change "Allowed Plugins" to: "Show all plugins, even those marked as experimental".
    – SaultDon
    Commented Jan 12, 2012 at 22:58
  • I ended up playing with this plugin a little bit tonight and it actually worked better for me since I didn't have to use a GRASS layer and could just convert my current shapefile. Commented Feb 21, 2012 at 5:18
  • I had to do it in two steps for my very detailed but jagged digitising: first simplify (eg Lang algorithm), and then smoothing. Worked a treat. Commented Aug 12, 2012 at 14:27
16

Using QGIS + GRASS plugin:

Add the Grass toolbar from the "Manage Plugins" window. add grass tools plugin to qgis

Your lines will need to be a grass vector, so convert them into a new or existing GRASS mapset.

From the GRASS toolbar, select GRASS Tools... enter image description here

Look for the module: v.generalize (WIKI tutorial here)

You can then choose several different generalizing algorithms: GRASS tool v.generalize algorithms selection

Note the algorithms: Chaiken, Hermite or even Sliding Average. There are several others as well!

The differences can be seen in the wiki pictures: v.generalize simplify differences example

from Wiki: "Note, that a difference between "Chaiken" and "Hermite" is that the lines produced by "Chaiken" "inscribe" the orginal lines whereas the "Hermite" lines "circumscribe" the original lines as can be seen in the picture [above]. (Black line is original line, green line is "Chaiken" and blue is "Hermite")


Using uDig + jgrasstools or grass:

If you have difficulty getting desirable results from GRASS's v.generalize, try the latest version of uDig with jgrasstools. You can also grab the grass jar from the same place as jgrasstools.

Once uDig is installed and up and running, enable the Spatial Toolbox: Window > Show View > Other... enable spatial toolbox in uDig

Un-dock the toolbar for easier readability (right-click Spatial Toolbox tab > Detach...): detaching spatial toolbox in uDig

Load the required jgrasstools and grass (optional) modules: loading jgrasstools/grass into udig

Don't forget to set your grass parameters (point to grass executable or bat file on windows, or grass command in linux ie, /usr/bin/grass) if you load the grass jar file as well: setting grass parameters in uDig

Finally! Using the tools from jgrasstools (not grass) you can generalize the line easily with Vector Processing > LineSmootherJaiTools Vector Processing to LineSmootherJaiTools in uDig

Be sure to set the input and output properly (works on Shapefiles only, so no need to convert your data to mapsets/locations for grass): input and output settings for Spatial Toolbox in uDig

Once done setting the smoothing tolerance (0.0 - 1.0) and input/output, press the Play button on the Spatial Toolbox window (top right): play module in Spatial Toolbox for uDig

Results:
uDig simplify jgrasstools results...

6
  • Does this alter the original data or does it filter it in a way before QGIS renders it? Commented Jan 12, 2012 at 21:27
  • Ah, that is answered here: "(Line) smoothing is a "reverse" process which takes as input a line and produces a smoother approximate of the original. In some cases, this is achieved by inserting new vertices into the original line, and can total up to 4000% of the number of vertices in the original. In such an instance, it is always a good idea to simplify the line after smoothing." from grass.osgeo.org/grass64/manuals/html64_user/v.generalize.html Commented Jan 12, 2012 at 21:29
  • So it seems like this is something you'd likely would apply once you've confirmed your lines are all correct and don't need further editing (unless you want to adjust all the additional vectors and then smooth it again) Commented Jan 12, 2012 at 21:31
  • @spline Yea, because you have to work with a "grass dataset" which is essentially - NOT a shapefile, you would want to make sure the original shapefile was complete. Simplifying the line to eliminate extra vertices is an option as well depending on how long the line is and the amount of vertices present in the bezier curve.
    – SaultDon
    Commented Jan 12, 2012 at 21:39
  • Oh my word, grass makes no sense to me... map names, location names, dbase, PERMANENT... I tried to 'discover' how to use this answer (with admittedly no prior knowledge of grass), and failed miserably. Files seem to go where you least expect (tho I guess they're not files?), I couldn't choose my converted layer in the generalise dialog after finally finding out how to select a map (not that I know what is meant by a map)... nightmare. Looks the goods if I could work it all out though :) Commented Aug 12, 2012 at 14:30
4

You can use geometry generator to smooth without changing the original data:

enter image description here

2

There is a Smooth geoalghoritm under Processing Toolbox -> Vector geometry -> Smooth.

smooth

This algorithm smooths the geometries in a line or polygon layer. It creates a new layer with the same features as the ones in the input layer, but with geometries containing a higher number of vertices and corners in the geometries smoothed out.

The iterations parameter dictates how many smoothing iterations will be applied to each geometry. A higher number of iterations results in smoother geometries with the cost of greater number of nodes in the geometries.

The offset parameter controls how "tightly" the smoothed geometries follow the original geometries. Smaller values results in a tighter fit, and larger values will create a looser fit.

The maximum angle parameter can be used to prevent smoothing of nodes with large angles. Any node where the angle of the segments to either side is larger than this will not be smoothed. For example, setting the maximum angle to 90 degrees or lower would preserve right angles in the geometry.

If input geometries contain Z or M values, these will also be smoothed and the output geometry will retain the same dimensionality as the input geometry.

1

There is another way, possibly this way only since version QGIS 2.0:

Under Processing>Toolbox you can access GRASS and SAGA Tools. For smoothing, there you find v.generalize, but also line simplification from SAGA. These tools work on regular shapefiles, so no grass vector is needed:

enter image description here

Batch mode is not that good solved yet (right click in the right-hand menue and choose "Execute as batch", since one has to choose every single file manually. The generalizer plug-in mentioned further above lets one choose many files more simply, but this only works right now if one does not specify a file to save to, otherwise the plug in crashes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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