5

I am developing a few scripts in Python for QGIS 1.8 to automate some geo-tasks and one of them would be to calculate the shortest distance from a hospital to each building in a town.

I would like to take advantage of the already existing Qgis plugin but, as it is a C++ plugin, I am not sure whether it is possible to access it from Python? Is there a binding or a trick for that?

If not, any further advice would be appreciated! As the base data is OpenStreetMap data stored in a PostGIS DB, I may also try with pgRouting. But the QGIS plugin would be my favourite choice if possible.

PS: this question is close to this one: Is there a way to access QGIS plugins in Python? but I believe it's still different enough to be worth a new thred.

asked Apr 28, 2013 at 19:00

3 Answers 3

3

gis-lab.info has a tutorial on using the network analysis library in QGIS using Python. It's not in English but Google Translate should be able to make it comprehensible. Good luck!

answered May 1, 2013 at 8:12
3
  • 1
    The Google translation doesn't really help, cause it's a very poor translation. But using your examples of code, I somehow manage to get it through. спасибо Commented May 2, 2013 at 6:19
  • Btw, that wasn't my blog post. I just linked it. Glad to know it helped though. Did it answer your question? Commented May 2, 2013 at 6:58
  • I'm still working on it but I think it did solve it yes, thx Commented May 2, 2013 at 11:39
2

There's a tutorial for the Network analysis library in the QGIS documentation that covers building a routing graph as well as shortest path and service area calculations.

underdark
84.9k22 gold badges237 silver badges418 bronze badges
answered May 26, 2016 at 23:44
0
1

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.

answered Nov 22, 2016 at 19:45

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.