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

1
  • 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 at 10:40
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

1
  • Yes, I misunderstood this vertex_index column. I thought the column was arbitrary/not related to my goal Sep 14 at 11:13
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).

Not the answer you're looking for? Browse other questions tagged or ask your own question.