I'm quite new to QGIS and trying to figure out how to analyze the following problem.

I have three layers:

  1. settlements point layer with 253 entries
  2. waste treatment facilities point layer with 24 entries
  3. roads polyline layer

My problem is to find the distance between each settlement from layer (1) to each treatment facility in layer (2), however it has to be subjected to roads (layer 3), namely instead of getting aerial distance matrix I am looking for to the matrix that describes the actual driving distance.

How do I perform this analysis with QGIS 1.7 (note that I don't know how to use PostGIS layers, if relevant)

  • what plugin can or should I use?
  • Should the polylines be connected to the points in both layers?

2 Answers 2


A short description of the working process (GRASS-GIS) as @gmacfalane asked.

  1. I've performed the analysis as described in GRASS-GIS 7.0 svn. Using Linux-Mint 14 as OS. That is since I had difficulties to run the requested functions on Windows OS.

  2. I've imported .shp files that were created in Q-GIS to the GRASS. It was easier to me to create data on Q-GIS, but grass has all necessary functionalities for this purpose.

  3. I've used v.build and v.clean to build topology for my network (road shp file)

  4. I've united all nodes (settlements and waste treatment sites) to on shp file. Added a column that distincts each type of node from the others - and fed data in it using the calculator. e.g. new_col = 10000 + id for all settlements, 20000 + id for all recycling sites, etc. Then I've assigned that column to be the new id (category column) - v.reclass can be used here.

  5. Use v.net (operation=connect) to connect all nodes to your network. I've used the threshold of approx. 4,500 meters.

  6. Use v.net.allpairs to calculate the distance between each two pairs of points on your network.

  7. I've exported the data to a csv file using v.db.select and loaded it to Excel. Data forms in one cell for each line, separated with |. If I'm not mistaken - I filtered all source point (from_cat column) to be the settlements, thus having a from_cat of between 10000 - 19999.

  8. Then I have received a table that contain the following: from_cat, to_cat, distance/cost

  9. I have separated the data set by source (to_cat) and built a matrix for each treatment type. Then I've formed further analysis to transform it to cost matrix and find the cheapest route from each settlement to each type of treatment site.

You can find explanations about the functions (italic) in grass-manual. It is also recommended to search in and sign up to the grass mailing list. It was very helpful.


It has been a while and though there are answers about it somewhere in gis Q&A history, I've decided to use my question to share some of my findings regarding QGIS network analysis.

As @simplexio kindly suggested, postGIS with PgRouting is an option, though too complicated for me. I found out that with QGIS 1.8 the GRASS 6.4.2 plugin is quite sufficient to help with network analysis. It is easy to operate (since the plugin uses QGIS GUI, and some commands), the manual is easy to navigate and importing QGIS files or others is quite easy.

I hope to finish my work soon (overcoming some pc-related technical difficulties) and to upload my working process, since as a begginer it was the hardest for me to find a suffcient document or handbook to guide me through the process.


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