5

I have a points layer with random points located along a route (polyline layer). I was wondering if there is a simple way to give a sequence number to each point in the order they show up along the route.

I am using QGIS 3.8, but I am very green and struggle with the lingo. I did install the LRS plugin hoping it might be a straight forward solution for me, but I can't make sense of it.

Taras
  • 32,823
  • 4
  • 66
  • 137
Nicci
  • 51
  • 2

1 Answers1

8

If your route (polyline) layer's name is Route1 which has an id field (fid), and the point layer is Bears like below example.

enter image description here

Open the attribute table of the Bears (point) layer and start the Field Calculator.

enter image description here

Create a new field (Dist) which shows the distance along the line by an expression:

line_locate_point(geometry:=geometry(get_feature('Route1','fid','1')), point:=$geometry)

Then start Add autoincremental field (Processing Toolbox > Vector table).

enter image description here

Choose the distance field you have just calculated as Sort expression.

I think you should set the start value at 1, otherwise the first bear will get the number zero like below.

enter image description here

Kazuhito
  • 30,746
  • 5
  • 69
  • 149
  • 1
    Sorry I have not been able to try this until now. This worked perfectly! Thank you Kazuhito. Thanks also to @taras for chiming in. – Nicci Oct 08 '19 at 02:23