8

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? enter image description here enter image description here

2
  • Could you please edit your question by adding a screenshot of what you have set in the Vector field marker dialog?
    – mgri
    Commented Apr 24, 2017 at 21:12
  • @mgri I have added the screenshot you mentioned. I set the X and Y attributes to the correspond with my X and Y velocity vectors from my model output and it automatically scales the default vector field lines. When I Click on "simple line" beneath "Line" in the marker tree, I select "Arrow" as my Symbol Layer Type. This is where I get hung up and am unable to scale the arrow head proportionally with the line.
    – spearl
    Commented Apr 25, 2017 at 19:29

2 Answers 2

7

You should get the desired output by recurring to a custom expression.

Firstly, click on the Edit... button for the Head length option:

enter image description here

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:

enter image description here

4
  • 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?
    – spearl
    Commented 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.
    – mgri
    Commented Apr 27, 2017 at 8:18
  • 1
    @mgri +1 Very nice solution, that also can bb applied for the thickness.
    – Jakob
    Commented Apr 27, 2017 at 10:11
  • 1
    @mgri You are correct. I think this should work. Thank you!
    – spearl
    Commented Apr 27, 2017 at 16:36
6

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:

enter image description here

Attribute table:

enter image description here

Map:

enter image description here

If you want the hydrology map with the same arrow line width, this might not suite you, since the entire styled object is scaled.

1
  • 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.
    – spearl
    Commented Apr 25, 2017 at 19:33

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.