I want to retrieve the nearest line to a point with the GRASS function v.distance(). But I think I do not fully understand how to use this function. What I have are two layers (in the same CRS -> EPSG:31255): one point-layer which contains the locations of all my sensors and one line-layer which contains a streetnet. The following picture shows both my layers: enter image description here

With v.distance, I want to retrieve the nearest line (street) for each point (sensor). Furthermore, I want to update my point-attribut "edgeid" with the id of the nearest line. enter image description here

EVIS_Stat_Sensorik_.. is my point-layer and Reprojiziert is my line-layer. For the upload string I used the "to_attr"-String because the relation between the pointlayer and the linelayer should not be based on the distance, but on the id of the nearest edge. So that the edgeid-attribut will get updated by the function and not some other attributs of the pointlayer. For the "Column name where values specified by upload option.." I chose edgeid because the edgeid should get updated. For the "Column name of neariest feature.." I chose id, because the attribut edgeid of the pointlayer should be updated WITH the id of the nearest line of the line layer.

But the problem is, if I run the algorithm, the output is a NEW pointlayer which is identical with the given input pointlayer EVIS_Stat_Sensorik_.. and the edgeid-attribut of BOTH the input and output pointlayer is still empty. So I do not understand where I can see the results of the algorithm. In the following picture you can se the attributtable of my output-linelayer named "Nearest": enter image description here

I have looked through a lot threads and the duplicate questions do not help me either (How to estimate distance from points to line feature with v.distance? , Nearest distance between point layer and line layer, QGIS, Finding nearest line to point in QGIS? ). Any suggestions?

  • What are the "threads" that you have looked through? If they are Q&As on this site then please include links to them.
    – PolyGeo
    Commented Nov 29, 2017 at 22:17
  • Have you found a solution? I'm struggling with the same problem. Commented Mar 21, 2018 at 18:21
  • @Temporalista Hey, I have solved the problem by using the NNJoin plugin! This performs a join operation (on the distance) of two layers (in my case, one point-layer and one line-layer. Hope this helps you too.
    – applebrown
    Commented Mar 23, 2018 at 6:26
  • Thanks for the update. I've also found a solution/bug: The id attribute to be joined must be type text (string). I'll post a full answer below. Commented Mar 26, 2018 at 13:03

2 Answers 2


I'm not sure why this is not working for you. Can I suggest to try in GRASS itself, standalone. Once you have it working there, then switch back to the QGIS Processing framework.

Note that the output layer from v.distance is just the connector lines between the "from" points layer to the "to" lines layer. So assuming you have columns: "edgeid" in the points layer and "id" in the lines layer, and the columns are the same type (both text), then the command would be:

v.distance from=<points> to=<lines> output=connectors upload=to_attr column=edgeid to_column=id

After that completes, you should have the line "id" value of the closest line in the "edgeid" column for each point.


The GRASS v.distance function did not use to work in QGIS Processing. See GRASS v.distance in QGIS not working. According to https://issues.qgis.org/issues/5954 and https://issues.qgis.org/issues/12817, it should be fixed now.

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.