I'm trying to do a shortest path analysis on my network. In order to prepare the network and attach polygon centroids to the roads, I used GRASS' V.NET operation=connect. the problem with this approach is that instead of connecting points to nearest line, it connect nodes to nearest line OR node which in turn results in unrealistic paths. For example, as you can see in the screen shot, nodes in the central region instead of being connected to the nearest road, are connected to the line that is three time further away.

Is there a way to fix this?

I'm using Grass 6.4 on Mac.

enter image description here

  • Hi Pey Man. Please mention GRASS version you use and the syntax you have used to receive the result demonstrated by the image.
    – dof1985
    Apr 1, 2013 at 15:33
  • 1
    For vector networking, use GRASS GIS 7 rather than 6 due to many improvements.
    – markusN
    Apr 3, 2013 at 16:53
  • @Alex. Have you able to solve this proble? I am facing the same issue.
    – Case Msee
    Feb 23, 2021 at 0:18

1 Answer 1


If I understand your goal and what you mean by "attach" properly, I think you could use GRASS v.distance tool to find the nearest road feature for each point and create line links connecting them. The tool also allows you to upload attributes from the point layer to the line layer. Ostensibly one can do that with more than one attribute field. However I have only been successful in transferring one attribute field at a time (I'm sure I'm just not doing something right). The single attribute field is sufficient if one uses 'category' or other unique ID as the transferred attribute field; one can then join other attributes from the point layer to the line layer using that shared key field.

I was accessing GRASS tools via QGIS 2.2 (not Processing/SEXTANTE plugin, which in spite of its general excellence kept locking up on this task for me). "Pep", you were obviously already loaded up in GRASS, but here's how I went about it, anyway:

-In QGIS, add a field to attribute table that will soon accept unique identifier (ie, 'cat' in GRASS) of nearest feature

-Create new GRASS mapset and import the line and point layers into GRASS with v.in.ogr.qgis

-Run v.distance tool, choosing 'Category of the nearest feature' for "Values describing the relation between two nearest features" and the name of the newly created attribute field for "Attribute field to (over)write"

-If needed, join attribute tables using newly created common key field. I did this back in QGIS after using v.out.ogr to get both points and lines exported back to shapefiles (note: watch the CRS) under the layer Properties > Join tab.


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.