5

I have lines representing curving streams and want to angle symbols at various points on the streams so that they are perpendicular to the angle in their particular locations.

What QGIS seems to do is give each point an angle that possibly represents the angle between the top and bottom of the stream. I've looked into writing an expression, but there doesn't seem to be a way to include degrees or angles as components.

I'm using the LRS plugin for these layers.

Picture for reference

  • 1
    To clarify: you have a line layer and you would like markers every-so-often that display perpendicular to the line? something like this: link ? – Jesse McMillan Jan 12 '16 at 1:17
  • I have markers but yes, that orientation is essentially what I'd like to do – Scolopendra73 Jan 13 '16 at 16:54
2

Not sure if this is what you're looking for, but if you use the Marker line Symbol layer type, you can set marker placement and rotation: enter image description here

The rotation field can be set by expression or field, and is relative to the angle of the line.

Please let me know if I've misinterpreted your question

  • Thanks Jessee, but I'm using points, not lines. This method does not seem to help with points. – Scolopendra73 Jan 13 '16 at 20:35
  • Oh so you have a point layer separate from your line layer for the markers? What does your data look like, can you post some screen grabs or something? – Jesse McMillan Jan 13 '16 at 21:09
1

I'm not sure if your points' centroids are next to your lines or exactly on the lines but if they are next to them, this might helps:

Make sure that your original marker point layer, let's call it Original, has got a column including unique numbers for each point and call it "id", and another column, called "rotation_2" (real number).

  • Using v.distance tool from Processing Toolbox, you can create perpendicular lines that join your marker points with the closest part of the lines (in your case to the curving streams). The resulting output will be two new layers: a point layer, named Nearest, and a line layer, named Distance. Line layer includes short "join-lines" that connect your points with the curving streams' layer perpendicularly.

  • After that, you can calculate the bearing of the small "join-lines" (Distance layer) in Field Calculator with the following expression in a new column, let's call it "rotation_1" and I suggest to set it for real number:

    (atan((xat(-1)-xat(0))/(yat(-1)-yat(0)))) * 180/3.14159 + (180 *(((yat(-1)-yat(0)) < 0) + (((xat(-1)-xat(0)) < 0 AND (yat(-1) - yat(0)) >0)*2)))

  • Next, using Join Attributes by Location, you can join Distance layer to Nearest layer, set Geometric predictate for 'touches' and Joined table for 'Keep all records'. Now, you have a new point layer again, called Joined layer. This layer should have a column which has the same "id" fields as your Original layer.

  • Go to Original layer's Layer Properties > Joins and add a vector join where Join layer is the Joined layer and Join and Target field are the "id" fields. Choose "rotation_1" field to be joined.

  • Go to Original layer's Field Calculator and add the values of the joined "rotation_1" column to the "rotation_2" column.

  • Go to Original layer's Layer Properties > Style, choose a Marker Type, and set "rotation_2" column to be the Rotation value.

  • Is there any way to achieve this where the point layer does coincide precisely with the line layer? – Nathan Oct 29 '17 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.