1

I have simple question, how can i export angles from Advanced Digitizing Panel do attribute table? . For example , i want to draw a line of length 100m at angle -45 degree. I do it using advanced digitizing panel but i want this specific -45 degree value in my attribute table, how can i do it?

  • See: https://gis.stackexchange.com/a/397498/88814 – Babel Nov 03 '21 at 21:18
  • Im sorry but i dont know where i have to put this code. In field calculator it always get en error. Do I have to do something before? Im newbie in QGIS sorry – Przemysław Karbowiak Nov 04 '21 at 12:12
  • You should be able to use the expression in field calculator. Be sure to replace 20 on line 3 with the index of the vertex at which you want to calculate the angle: for vertex no. 3, replace 20 with 4 (vertex calculation starts with 0, the expression starts with 1), see: https://i.stack.imgur.com/u8VUh.png – Babel Nov 04 '21 at 12:45
  • Ok i get some results. In poligon layer it works but in line it doesn't. Maybe is it something with CRS?? https://ibb.co/CQnJ8wx <-- here is a picture. What am i doing wrong??? – Przemysław Karbowiak Nov 04 '21 at 13:32
  • You don't have an angle in this line! It is just a simple line, connecting two points, so it can't identify any angle. – Babel Nov 04 '21 at 14:33
  • Ahhh thats the problem. So in your opinion there is no option that i can get an angle of line "like in advenced digitizing mode" in attribute table? – Przemysław Karbowiak Nov 04 '21 at 18:55
  • As it becomes clear from your comments, your're looking for the azimuth of a line. You should add this information to the question, including the screenshot (edit your initial post). – Babel Nov 04 '21 at 20:13

1 Answers1

1

From your comments, it becomes clear that you're looking for the azimuth of a line = angle clockwise from North.

enter image description here

To do that, use the following expression:

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

Screenshot: azimuth is 315 degrees, this corresponds to -45 degrees (360 - 45= 315): enter image description here

Babel
  • 71,072
  • 14
  • 78
  • 208
  • Thank you very much for answer ! :) – Przemysław Karbowiak Nov 07 '21 at 11:16
  • 1
    You're welcome. As a new user, please be adviced that this side tries to avoid "thank you" messages. Instead, it encourages you to accept the answer and/or upvote it: click the checkmark right to the answer to accept it - see: https://gis.stackexchange.com/help/someone-answers Just click the checkmark, see here: https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235 – Babel Nov 07 '21 at 13:10