What is the best method to calculate the distance from the nearest road for a series of address points in QGIS, having a very big dataset? (QGIS 2.0.1, Win XP)

I read the answers to previous similar questions:

Measuring the distance between lines and points in QGIS

Drawing perpendicular lines in PyQGIS?

Calculating minimum distance between points and polygons in QGIS?



  1. MMQGIS plugin find the disance to the nearest node of a line network, not the shortest (perpendicular) distance to a line.

  2. R and Python proposed scripts correctly works for small datasets and can be implemented in the modeler, however for my job I have 530 points and a regional street layer with about 135'000 features, and cycling through all the features then taking the shortest distance for all points will take an enormous amount of time

  3. I have problems in making GRASS work in QGIS 2.0.1 (GRASS in QGIS not working (windows XP)).

  • 1
    I managed to calculate the minimum distance in QGIS 1.8.0 through the GRASS plugin and the v.distance tool. It takes about 15 minutes to execute (plus the time spent to correctly set GRASS and import layers...). Why is ArcGIS (es, join by spatial location) still so rapid in comparison?
    – mic_cord
    Oct 7, 2013 at 9:12
  • 1
    It is a matter of having a spatial index and code optimized for the task. I just checked with our routing library (RW Net 4) and it can do 2000 such calculations per sec for a street network of app. the same size as yours. Making it about 4000 times faster than your GRASS plugin. Oct 7, 2013 at 9:25
  • 3
    Postgis should do it fast Oct 7, 2013 at 17:27
  • 1
    @mic_cord Can you please give a detailed explanation of your GRASS plugin v.distance method? I have successfully gotten v.distance to work using GRASS outside of QGIS, but am unable to get it to work within the Processing toolbox (QGIS 2.6).
    – user25976
    Mar 6, 2015 at 20:40

2 Answers 2


We were solving similar problem. The best and fastest way for us is:

  1. Rasterize line layer (Raster/Conversion/Rasterize...)
  2. Convert to Proximity (Raster/Analysis/Proximity...)
  3. Use plugin Point sampling tool to get values for all your point from raster

Some of the answers to Measuring the distance between lines and points in QGIS recommend the NNJoin QGIS plugin (http://arken.nmbu.no/~havatv/gis/qgisplugins/NNJoin/). It will do a nearest neighbour spatial join and include the distance in the result. The NNJoin plugin uses a spatial index, so it should handle reasonably large datasets.

  • Tveite, I second your suggestion. I was very surprised that this plugin worked faster than a recommended package in R (i.e. geosphere::dist2Line).
    – Johanness
    Jan 15, 2020 at 9:06

Your Answer

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

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