1

I have a polyline layer in QGIS, and I am trying to get the list of lat longs of each of the vertices and their path.

As you can see from the image below, I have tried the steps mentioned in this answer. I have extracted the vertices of the lines and I can calculate the lat long of each of these vertices.

But the only thing missing is the trail/path/direction of the coordinates. I need to extract, not only the lat longs of the vertices but also the direction (coord A to coord B to C to D etc., or D-C-B-A, order so far is not important yet).

enter image description here

Germán Carrillo
  • 36,307
  • 5
  • 123
  • 178
user2552108
  • 183
  • 4
  • I suggest you have a look at the extract vertices tool, which extracts all vertices and adds the angle of the line at the vertice, as well as its distance along the line. – Erik Sep 14 '21 at 10:40

2 Answers2

6

When you use "Extract Vertices" tool, it gives a clue for the directions. It adds vertex_index column.

enter image description here

Then extract the vertices to CSV and set GEOMETRY = AS_XY

enter image description here

Kadir Şahbaz
  • 76,800
  • 56
  • 247
  • 389
3

QgsLineString has a numPoints method and a pointN method so combining those in a for loop should do what you want. But it might be easiest to just use the points method to get a list of the points (I can't think of any reason they would not be in order along the line).

Ian Turton
  • 81,417
  • 6
  • 84
  • 185