Saturday, 20 February 2016

qgis - Scaling vector field marker arrow based on attribute?


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



Answer



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


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...