2

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.

  • Are your points lie exactly on lines or they are located alongside the lines? What should be considered as a 'starting point' from which counting shall start? Is there any sort of relation between points and polylines, e.g. "ref_id"? – Taras Sep 26 at 5:17
5

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

  • 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 8 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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