0

I have a shapefile containing a lot of lines which I'm trying to separate based on direction.

Is there any way to calculate the line bearing against a compass (in degrees or just as North / North-East / East etc.) add this calculated value as a column to the shapefile?

Taras
  • 32,823
  • 4
  • 66
  • 137
SG3141
  • 41
  • 1
  • 6
  • 2
    Can you some Field calculator? There is for instance a function angle_at_vertex(geometry:=$geometry,vertex:=0) – Taras Mar 01 '19 at 09:31
  • 3
    Hi Will, Did you do some research? I just googled your question and found some answers: https://gis.stackexchange.com/questions/24260/how-to-add-direction-and-distance-to-attribute-table, https://www.northrivergeographic.com/qgis-azimuth-distance-plugin, https://gis.stackexchange.com/questions/55449/how-do-i-find-vector-line-bearing-in-qgis-or-grass – PieterB Mar 01 '19 at 09:31

1 Answers1

1

Here's something simple that worked for me.

  1. Extract vertices from your line layer.
  2. Install Shape Tools Plugin. Use Create Shape function and create a "line of bearing". For the Azimuth Field input select ANGLE. For the distance field, nothing. Then specify a standard length for all the lines.
  3. Run it and you'll get a new line layer with the extended lines. If you need the lines to go the other way, reverse the azimuth values.
Kadir Şahbaz
  • 76,800
  • 56
  • 247
  • 389
Juan C
  • 11
  • 2