I have 2 vector shapefiles (one line, one point), and I have tried at least 4 ways to try to get the distance matrix at one time (and most concern the directions of each river segment)

  1. quantum navigator
  2. GRASS tool - v.net.allpairs
  3. pgrouting
  4. roadgraph plugin

In the end I think that roadgraph plugin is the one which is the closest to my goal, and it also can set the directions of the river, but I can't modify it to get the distances between all pairs of points(and I want to get this in matrix form).

What/How could I do? Is there any other way to get this distance matrix on qgis?


Currently there is no purely QGIS-based solution for this problem.

I think your best bet to create a distance matrix is to use pgRouting. You said you tried it. Why didn't it work for you?

  • After following your guide in anitagraser.com/2011/02/07/a-beginners-guide-to-pgrouting, I was stuck in the "Creating a routable road network" state, I open my postgis manager in QGIS, the metadata zone shows some details like connection details, privileges, and PostGIS, but right below the PostGIS label shows "PostGIS support not enabled".If I try loading data to PostGIS directly, I would see the error:Something's wrong:["'shp2pgsql' \xa4\xa3\xacO\xa4\xba\xb3\xa1\xa9\xce\xa5~\xb3\xa1\xa9R\xa5O\xa1B\xa5i\xb0\xf5\xa6\xe6\xaa\xba\xb5{\xa6\xa1\xa9\xce\xa7\xe5\xa6\xb8\xc0\xc9\xa1C\n"] – Heinz Mar 25 '13 at 8:58
  • @user15633 Sounds like the database is not PostGIS enabled. Did you install PostGIS and create a database that contains the necessary spatial classes and functions? If not, that should be a different question. – underdark Mar 25 '13 at 9:25
  • thank you, I would try your method later, but I have one question:can pgrouting handle the problem of direction?I mean if point A is downstream to point B in the same stream network, I would like to get the distance from B to A but no A to B, cuz the flow itself would not go from A to B. – Heinz Mar 25 '13 at 9:44
  • recently I have tried GRASS module to achieve the goal, but I think it's much more efficient using pgRouting to get the distance matrix – Heinz Feb 24 '14 at 14:37
  • @underdark 5 years ago you said that there were no QGIS-based solutions for calculating shortest path between all pairs of points in a network. Does that still hold true? – M Taglia May 3 '18 at 16:05

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