2

I need to generate routes based on a consecutive set of points exactly as given in this routing script by Anita Graser.

Image from: https://anitagraser.com/2013/10/19/a-routing-script-for-the-processing-toolbox/

As given in this image, I have a layer of consecutive points as well as a network layer. I need to generate a path along the network using these points.

I tried using her script modifying the lines of code so that it may work in QGIS 3.x

However I get an error indicating that the Network Analysis library couldn't be found.

Would be grateful for any method I could use to achieve routing as mentioned here or a way I could edit this script so that it will function in QGIS 3.x

  • Suggest you clarify the question so you don't need to read the code. "Generate routes based on a set of points" is a bit ambigious. Do you mean travelling salesman? Or are the points ordered and you just want a path that connects them in sequence? – hexamon Oct 8 at 7:04
  • I read the blog post you linked in the comment to my question and understand now that you want to route a series of consecutive points. However, I think it's important to describe this in the question itself, so that it still makes sense even if Anita Graser's post disappear. – hexamon Oct 8 at 7:11
  • Right. Will do. Thanks – Nandula Oct 8 at 7:35
1

I suggest organising your points into start and end layers like so: Layer 1: Point 1-2, Layer 2: Point 2-3, Layer 3: Point 3-4 and so on, based on their order.

[Edit: I meant v.net.distance, not path] Then you can run GRASS7 v.net.distance in batch mode on all pairs and dissolve the resulting lines to form a continous path in the network.

Alternately, if it's not a very large dataset and depending on the distribution of points, you could try running v.net.allpairs from GRASS7 on all the points and do some manual or automated cleaning afterwards. This is a very brute force approach though and doesn't scale well.

An alternative could be to use the QNEAT3 api to script a similar solution, where you iterate through the points to connect them.

https://root676.github.io/

Perhaps you could replace the relevant calls to network functions in Anita Graser's script with QNEAT3 functions?

0

Another more unorthodox way would be to use snapping.

First snap the points to the network with "Snap geometries to layer" from the processing toolbox.

Then use "Points to path" to connect the snapped points by lines.

Then use "Snap geometries to layer" on the created line to snap it to the network.

I got some reasonable results by playing around with tolerances on a dummy dataset:

This was my input dummy data; ordered points and a network: enter image description here

This is after snapping the points to the network: enter image description here

This is the lines created by joining the snapped points: enter image description here

And this is the final result where the joined line is snapped to the network: enter image description here

However, this approach assumes that you don't need any other cost than distance. It would of course also be very sensitive to density of the points and the network. Sparse points in a dense network will probably be hard to get something useful out from this approach. But it's neat and simple if it works.

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.