This question was asked many times and I could reference endless GIS-SE links here. Most of them suggest using pgRouting, which is not an option here. I have to use QGIS (for other technical questions). Others suggest QNEAT3 plugin, which is not working as expected (see here).

So I'm looking for a definitive answer, which can be referenced forever here and put an end to new ones (and, of course, put an end to my recurrent problem). I know it is possible to have a purely QGIS-based answer, as pointed out in the documentation. With my somewhat superficial python knowledge, I can't do it myself, but I know it's possible.


I have three layers:

  • m points in a map layer origins;
  • n points in a map layer destinations;
  • k arcs/paths/lines in a map layer network;

I need a distance matrix of shortest paths from all m points to all n points through that network.

Almost a solution

The Shortest path (point to layer) tool is the closest solution you can readily have. Except by the fact you have to manually input the from coordinates picking it from the map. This can be really painful if you have 100+ from origins to calculate.

Easiest solution I can foresee

Some test datasets


The problem is how? I'm relatively new to QGIS and I'm not sure how to build a model or modify the native tools. Any insights are much appreciated!

  • Maybe you have problem with your network connection. QNEAT matrix work fine. – nagib Apr 9 '20 at 7:04
  • Unfortunately, it is not my network. Check here. I'd like would be that, because it would be simpler to solve. Shortest path tools of QGIS core works well, QNEAT3 doesn't. The problem is the QGIS core tools (GUI) don't do it from all origin points to all destination points. I have provided my test dataset on the above link. If someone manage to run QNEAT3, please let me know. The developer is not responding any more. Hope he is doing well. In times of COVID-19, when people stop responding it's a reason to worry. – Jecogeo Apr 21 '20 at 13:39
  • Updating the issue: PyQGIS cookbook has a partial solution to the problem. The question now is how to iterate through origin points so that we have m:n matrix (from all origin points to all destination points). Any contribution will be much appreciated! – Jecogeo Apr 21 '20 at 13:54
  • Maybe you could use the Shortest path (layer to point) or point to layer and the batch process option. Then you have to copy/paste the batch process line N times and change the end point. To be less tedious, I believe you could write a couple of lines, save the batch process and edit the JSON file by hand. Than import it back. – Daniel Apr 21 '20 at 14:44
  • another option to test (I haven't done it) is to create a new graphical model and when you run it, try to user the iterate option to change your start / end point at each run. This posts describes it a bit (gis.stackexchange.com/questions/312937/…) – Daniel Apr 21 '20 at 14:54

QNEAT3 is definitely the right choice for solving this task. As pointed out by you in the QNEAT3 issue you achieve faulty outputs using the OD-Matrix algorithms. I tested the dataset comparing QNEAT3 results with the native QGIS routing algorithms (which QNEAT3 is basically built upon) and was able to detect a bug related to the tolerance parameter not being wired to the QgsGraphBuilder. I will post a patch for this problem during the next weeks - to solve the problem on the fly you can also update the source code of your installed QNEAT3 plugin.

The solution for on QNEAT3 version 1.0.3 and should be fixed in future versions:

  1. Navigate to the QNEAT3 folder in the QGIS plugins folder
  2. Open the file Qneat3Framework.py
  3. Go to line 121 and add True, input_tolerance in the constructor of QgsGraphBuilder
  4. The line should now be

    self.builder = QgsGraphBuilder(self.AnalysisCrs, True, input_tolerance)

  5. Save the file and open QGIS or reload QNEAT3 using the plugin reloader.

  6. Test your analysis with the desired tolerance parameter.
  7. Enjoy the fixed result

Thank you for reporting this bug - you just triggered the release of QNEAT3 version 1.0.4. :)

  • 1
    This is definitely the definitive answer I was looking for. I was preparing a jupyter notebook to add here and enrich the question. But this is certainly not necessary anymore. We shouldn't reinvent the wheel when the wheel is already available to use. I'll award the bounty as soon as it is available (24h after open the bountied question). Thanks a lot! – Jecogeo Apr 21 '20 at 22:04
  • Glad I could help!, BTW: the QNEAT3 patch has been approved by the QGIS plugin repostiory managers already - you can upgrade any time. – root676 Apr 22 '20 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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