[GIS] Joining nodes to network lines ( and not other points) using GRASS

grassNetwork

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

Best Answer

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.

Related Question