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..
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?