I'm looking for a zigzag line symbol in QGIS. Is there perhaps an easy way to do this that I'm missing?
I have tried creating a marker line using a simple triangle marker (^) and adjusting the size of the marker and the marker placement interval until the traingles touched each other and appeared to make a nice zigzag line. This works for straight lines but around curves there are gaps between the triangles because the triangles aren't actually connected. Is there perhaps a way to join the markers together? Or another way to go about this? I would be very grateful for any suggestions!
(using QGIS 2.4.0)
[GIS] Zigzag Line Symbol in QGIS
linemarkersqgissymbology
Best Answer
It seems like there's no way to just symbolise the line as a zigzag: unfortunately, you'll have to alter the underlying data.
You can get a reasonably good zigzag line by first splitting the original line into many equidistant line segments, and then offsetting every other point by a fixed amount.
Here's a Python script that does this, taking NathanW's answer to How can I create random points along a polyline in QGIS? as a starting point. Save the code chunk into a file called
zigzag.py
in your~/.qgis/python
directory (or{User Directory}\.qgis\python\
on Windows), and then import it in the QGIS Python console by typingimport zigzag
. Then you can select one or more lines that you want to zigzagify, and typezigzag.createZigzag(<wavelength>, <amplitude>)
in the QGIS Python console, where<wavelength>
and<amplitude>
are the "length" and "width" of the zigzag segments, in map units.Here's an example:
As you can see, the zigzags aren't very nice near the original line's corners, but at least the zigzag line doesn't have any breaks.
If you use James Conkling's suggestion of smoothing the line first using Chaiken's Algorithm, the result gets much nicer:
Here's the script: