I'm new to GIS but thanks to the answers I got in another question here on GIS stack exchange I was able to increase my knowledge significantly. This question is related to an earlier question I asked and got answer, but since this is a new question, I thought better to ask a new question instead of continuing on the older one.

I have about 160,000 addresses (points) and a (vector format) map of roads and 10 city limits (polygon). I want to:

  • Calculate the distance from each of these addresses to the city borders (or possible the city centers - a point - if that is easier).
  • That is, for each city I want 10 distances. I don't just want the possibility to do it one by one - I want the total 1,600,000 distances once and for all!

I was earlier advised to use either Road Graph for QGIS og pgRouting for PostGIS. I have stated using Road Graph. I was able to import all the data into QGIS, install the Road Graph plugin, and calculate the distance between to points. My question now is:

  • How do I get Road Graph to calculate all the 1,600,000 distances? And can it at all be done with 'Road Graph'?


  • distance as in a 'straight line' distance?
    – nickves
    Oct 9, 2013 at 13:02
  • No, as in shortest path on roads.
    – Mace
    Oct 9, 2013 at 14:05

2 Answers 2


As far as I have understood Road Graph, it is very limited in its functionality. Only A-B routing on screen. No automation of processing.

  • Ok, thanks for the answer. Do you have another suggestion? Do you know if pgrouting can do this?
    – Mace
    Oct 9, 2013 at 13:09
  • I would primarily suggest my own offerings from www.routeware.dk, but I guess pgrouting can also do it. Oct 9, 2013 at 13:27
  • Thanks - looking for a free solution though.
    – Mace
    Oct 9, 2013 at 13:43
  • @Mace How big is your road graph (how many edges)? PgRouting should certainly be able to cope with 1-2 million routes without much fuss.
    – underdark
    Oct 9, 2013 at 15:03
  • @underdark I have three levels of roads varying in size (freeway, interstate, and small road). I don't know exactly how many roads each one has. Preferably, I want to use all three types of roads, and then penalize using the small roads and the interstates, is this possible in pgrouting? I think pgrouting is the way to go for me no matter what, so I will try to get it working.
    – Mace
    Oct 11, 2013 at 9:22

I had to do something similar once upon a time, before pgrouting was mature. I wrote a simple PHP script that would query for the road graph and perform a Dijkstra search (PHP made for an easy "query container"). In my case, this worked because my graph was small. I also made things easier by eliminating nodes that didn't actually branch. Eg, if A->B->C, I just combined A, B, and C into one geometry.

TL;DR You're going to have to write a bit of software. Dijkstra implementations can be found easily, but you need to feed data into them yourself. If your graph is large, you're going to need to find a way to simplify.

  • Thanks for the input. I think I will look at pgRouting before starting to code myself. It already includes a Djikstra search as far as I know.
    – Mace
    Oct 9, 2013 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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