Sunday 25 September 2016

Displaying azimuth of line in QGIS?




I have drawn a series of straight lines on a map joining different locations. The lines have a single vertex at each end. I am using the Ordnance Survey of Great Britain 1936 projection.


I now want to know the compass bearings I will have to walk to move from one location to the next.





  • Is there any easy way to get QGIS to calculate/display the azimuth of the lines I have drawn?




  • Better still is there any way to get QIS to actively display the azimuth of the lines as I am drawing them?




I am aware there is an azimuth function but the syntax appears to need the input of the coordinates of the vertices on either end of the line which would be very time consuming.



Answer



To display the azimuth, use the following expression



degrees(azimuth(start_point($geometry), end_point($geometry)))

To make it more fancy use


CONCAT(format_number(degrees(azimuth(start_point($geometry), end_point($geometry))), 2), '°')

enter image description here


To show the angle while digitizing, enable the advanced digitizing panel, the number next to a is what you are looking for.


enter image description here


Unfortunately, the second one uses a different origin line and rotation direction for the angle.


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...