Today’s post was motivated by a question following up on my recent post “Details of good flow maps“: How to create arrows with gradients from transparent to opaque?
The key idea is to use a gradient fill to color the arrows:
It all seems perfectly straightforward: determine the direction of the line and set the gradient rotation according to the line direction.
But wait! That doesn’t work!
The issue is that all default angle functions available in expressions return clockwise angles but the gradient rotation has to be set in counter-clockwise angles. So we need this expression:
Very beautiful Anita. Do you think a variable gradient line width is an implementable idea? For instance, when depicting river flows between two gauges, to illustrate the relative change in volume going downstream and gaining inflows, could the line width increase between two end vertices?
Thanks Bill! The arrow line start width and end width can be configured separately in arrow symbol layers. I think that should do what you want.
Great work! I also bought the book QGIS Map Design, so thanks for all your efforts.
I have one question though; how did you get to make the flow arrows curved instead of straight lines?
Thank you! The arrow symbol layer settings contain a “curved arrow” option. To draw a curved arrow, the line needs to have one intermediate point between start and end. Depending on the intermediate point’s position, the line is more or less curved.
your site is very useful! many thanks! one question: the first color of the gradient is ALWAYS at the end of the arrow? in my map it seems this rule is not applied :-(
The rule is same for all arrows. Check if all settings, particularly the reference point settings, are set up as shown in the screen shot.
Thanks for this tuto ! I’ve got a problem with the angle expression -but maybe it’s because of 8.2 version I’m actually using- it returns error “unexpected ‘(‘ expecting $end”. Have you got a solution so my fill could have a logical way (origin-destination)
Thanks a lot
Do you mean QGIS version 2.8? Can you try a newer version?
Yes sorry, Qgis 2.8.1 to be very specific. I’m working in an internship and the firm works on this version, it would be complex to ask a newer version for this project
The angle_at_vertex function has only been added in 2.18 (https://www.qgis.org/en/site/forusers/visualchangelog218/index.html#feature-new-expression-functions).
You’ll have to compute the angle in a different way if you cannot get a new version installed.
oupsi, rotation expression*