TEXT 40
QGIS Lines Start-End-Azimuth By mike on 28th March 2021 03:50:22 PM
  1. # Add defaults on Attributes Form to save calculated fields into layer (otherwise use Virtual Fields)
  2.  
  3.  
  4. # Start and end position and length in 5 separate attribute columns
  5. $x_at(0)
  6. $y_at(0)
  7. $x_at(-1)
  8. $y_at(-1)
  9. $length
  10.  
  11. # or
  12. format_number($x_at(0), 2)
  13. format_number($y_at(0), 2)
  14. format_number($x_at(-1), 2)
  15. format_number($y_at(-1), 2)
  16. format_number($length, 2)
  17.  
  18. # Azimuth in separate column
  19. CASE
  20.         WHEN degrees(azimuth(start_point($geometry), end_point($geometry))) > 180
  21.         THEN format_number(degrees(azimuth(start_point($geometry), end_point($geometry)))-180,2)
  22.         ELSE format_number(degrees(azimuth(start_point($geometry), end_point($geometry))),2)
  23. END

Hasta la pasta! is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.