6

I have line shapefile with different bus routes (each route consist of multiple line), in which I want to sequentially arrange the lines for each bus route based on the direction of route. I tried with QChainage, but couldn't achieve it.

Is it possible in QGIS?

enter image description here

Kadir Şahbaz
  • 76,800
  • 56
  • 247
  • 389
Sathish
  • 71
  • 4
  • 1
    Could you go into more detail what you mean by "sequentially arrange"? How should the final result look like? – Erik Jul 06 '20 at 08:05
  • i have continuous lines as shown in attached image. in this i wanna rank the links based on each segment.. right now i have done it manually. R_NB_1 (segment one), R_NB_2 (segment two) and goes on – Sathish Jul 06 '20 at 08:20
  • Should be doable using pyqgis and networkx module if you are ok with some python? – BERA Aug 14 '20 at 08:14

2 Answers2

4

Let's assume there is a polyline layer 'lines_test' with an imaginary bus route #1 (into town and from town), see image below

input

To get a sequence/rank of lines (polylines) in QGIS, there are couple of steps that can be followed.

Step 1. Use the "Explode lines" geoalgorithm that will create line-strings out of the original continuous feature.

step_1

Step 2. Here use the "Add autoincremental field" tool with "Direction" in the Group values by. It will sequentially arrange the lines for each bus route based on the direction of route.

step_2_1

and get the output:

step_2_2

If you are not satisfied with order of your vertices in some polylines use the ReverseLine reverse_line from the Advanced Digitizing Toolbar. Other details you may find in this thread Changing (flipping) line direction in QGIS?.

Taras
  • 32,823
  • 4
  • 66
  • 137
0

Perhaps the QGIS plugin "Lines Ranking" can help you. There is an article describing the algorithm.

You can check repository with code also

Dreamlone
  • 1
  • 1