I'm new on QGIS, and I'm trying to measure the distance between an address and every road in the city.

I used NNjoin but I got only the shortest distance between the address and the nearest road.

Is there a package or plug-in that I can use to calculate a distance between the address and all roads in the city?

1 Answer 1


As you have already tried NNjoin plugin, I assume you have a point layer which represents the address.

(1) Open the attribute table of your road (line) layer and start the Field Calculator.

(2) Replace 'point' of the syntax below by your actual point layername and run:

length(shortest_line($geometry, geometry(get_feature_by_id('point', '1'))))

If you also want to output the "shortest line" (a new line layer), use the Geometry by expression tool:

shortest_line($geometry, geometry(get_feature_by_id('point', '1'))) 
  • I tried this approach but it does not work. it doesn't give an error message through
    – Mr.M
    Commented Oct 11, 2019 at 22:49
  • @Mr.F Please double check your point layername and the id of the point.
    – Kazuhito
    Commented Oct 11, 2019 at 22:56

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.