3

I'm currently using the Road Graph plugin to find the shortest path in a road network - however, I'd like to put this to a processing script (to be used in a model later) and the Road Graph Plugin has no API to be used in a model.

Is there a way to put the shortest path algorithm to a processing script and then use this script in a model?

I found some python scripts for networks/shortest path in the Python Cookbook and tried to put it to a processing script - but as I am a complete newbie with python I didn't get far..

enter image description here

The script should:

  • Take a roadnetwork (blue) and and a line vector layer (violet) as input
  • Put the start (green) - and endpoint (red) of the line as start and end of the path to be claculated
  • Use the intersections of the input line and the network as waypoints, that the path should follow
  • Find the shortest path (red ribbon) by routing through the network and save the path as vector layer

Can anybody help me with this script?

asked Oct 16, 2014 at 7:55

1 Answer 1

3

You can find multiple versions of routing scripts which use the QGIS network analysis library in my Github repository, e.g. https://github.com/anitagraser/QGIS-Processing-tools/blob/master/2.2/scripts/point_layer_to_route.py which converts an ordered set of points into a route.

None of the scripts use the intersections of an input line with the network. That's something you will have to add on your own.

answered Oct 16, 2014 at 17:16
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.