Page 1 of 1 (4 posts)

  • talks about »
  • symbology


Last update:
Sun May 28 19:05:11 2017

A Django site.

QGIS Planet

Straight and curved arrows with QGIS

After my previous posts on flow maps, many people asked me how to create the curved arrows that you see in these maps.

Arrow symbol layers were introduced in QGIS 2.16.

The following quick screencast shows how it is done. Note how additional nodes are added to make the curved arrows:

Geometry generator symbology

Say hello to geometry generators, a new way to use expression syntax to generate a geometry on the fly during the rendering process.
See more ›

A line gradient style hack

Today’s post was motivated by a question over on gis.stackexchange, basically: How to draw a line with a gradient?

The issue we have to deal with is there is no gradient line style yet … But there are polygon gradient fills. So we can buffer the line and style the buffers. It’s a bit of an exercise in data-defined styling though:

Screenshot 2015-01-11 22.49.41

Before creating the buffer layer, we need to add the coordinates of the line start and end node to the line attributes. This is easy to do using the Field Calculator functions xat and yat, for example xat(0) for the x coordinate of the start node and yat(-1) for the y coordinate of the end node.

Screenshot 2015-01-11 22.41.37

Then we can buffer the lines and start styling the buffers. As mentioned, we’ll use the Gradient fill Symbol layer type.

Screenshot 2015-01-11 22.49.54

The interesting part happens in the Data-defined properties. The start and end colors are computed from the measurement values from_m and to_m. Next, it’s important to use the feature coordinate mode because this will ensure that the coordinate system for the color gradient is based on the feature extent (with [0,0] in the upper left corner of the feature bbox).

Once that’s set up, we can compute the gradient start and end positions based on the line start and end node locations which we added to the attribute table in the beginning. If you’re wondering why Reference point 1 y is based on to_y (y coordinate of the line end point) rather than from_y, it’s due to the difference in coordinate origins in the geometry and the color gradient coordinate space: [0,0] is the lower left corner for the geometries but the upper left corner for the color gradient.

Screenshot 2015-01-11 22.42.35

As the title suggests, this is a really hackish solution for gradient line symbols. It will only provide reasonable results for straight – or close to straight – lines. But I’m very confident that we’ll have a real gradient line style in QGIS sooner or later.

Batch Application of QGIS Layer Styles

Ever had to apply the same style to multiple map layers? It’s a tedious task … if you don’t have MultiQML plugin by Gislab.

With MultiQML, you can apply a style to multiple raster or vector layers: First, select the layers you want to style (use shift/ctrl to select multiple layers), press “Apply style …” button and select the appropriate QML. That’s it!

MultiQML dialog

The tool even has an “undo” functionality called “Restore initial style”, which will certainly prove useful.

If you want to see MultiQML in action, Gislab provides a video tutorial on their plugin page.

  • Page 1 of 1 ( 4 posts )
  • symbology

Back to Top