I have discovered how to create vector lines to indicate flow direction and velocities. With a "vector field marker" symbol layer type, the lines lengths vary based on the data attributes. However, when using an arrow as a symbol layer type, I can only seem to get the line to scale and not the arrow head. I would like to scale the arrow head proportionally with the line based on the data attributes. Is there a way to do this?
2 Answers
You should get the desired output by recurring to a custom expression.
Firstly, click on the Edit...
button for the Head length
option:
Then, type this expression:
length(
make_line(
$geometry,
make_point(
$x + "Vel_X_ft_p_s",
$y + "Vel_Y_ft_p_s"
)
)
) / 3
which is saying, in an imaginary way:
"For the current feature, draw a head having a length which is 1/3 of the total length of the line."
You can obviously change the 3
number as you want and apply a similar rule if you want to do the same for the Head thickness
parameter (you have just learned how to do it).
Applying the edit on the Head length
parameter as above seems to work for me:
-
This is on the right track for what I am trying to do. I appreciate the help. When I tried this, it kind of brought QGIS to it's knees. Each point in my data does however have a velocity magnitude value. Does it make more sense to scale the arrow heads using magnitude and how would that change the code?– spearlCommented Apr 26, 2017 at 23:22
-
@spearl Could you elaborate? My solution should already lead to proportionally scale the head length of the arrow and it seems a good way of solving the issue. If you have the magnitude stored in a field, you may simply use the expression
"magnitude"/3
, but I don't know how the solution would change and if it would be better.– mgriCommented Apr 27, 2017 at 8:18 -
1@mgri +1 Very nice solution, that also can bb applied for the thickness.– JakobCommented Apr 27, 2017 at 10:11
-
1@mgri You are correct. I think this should work. Thank you!– spearlCommented Apr 27, 2017 at 16:36
An alternative more simple approach would be to use a SVG marker instead of a vector marker field, with just setting the scale and rotation.
SVG Style:
Attribute table:
Map:
If you want the hydrology map with the same arrow line width, this might not suite you, since the entire styled object is scaled.
-
Thanks for this. For this to work, I would have to calculate the rotation angle for each point before bringing it into QGIS. That is totally reasonable, but I wanted to avoid manipulating the raw data s much as possible for a more seamless procedure. I am currently using the vector field renderer plugin to get the look I am after, which temporarily solves my problem.– spearlCommented Apr 25, 2017 at 19:33
Vector field marker
dialog?