1

I am calculating the distance from remote locations, which I have as point vector data, to a road network, a line vector. I'm using QGIS 2.18.2.

As per this image, I've had success with using the integrated GRASS tools v.distance and v.net.connect to generate the lines to the road network (though with slightly different results between the two functions, hence the green and red). However, the attribute file of the new line layers generated take their attribute data from the roads they're connecting to, rather than the locations they originate from.

QGIS can give me the distance represented by the generated lines, but I need to associate those distances with the locations.

Is there a different function, or a subsequent one I should be using? Ultimately I want to end up with the distance to the road as an additional attribute of the original points.

enter image description here

1

Your next step could be with v.what.vect. This module uploads to a point vector some attribute from a nearby or intersecting line or polygon map table. Here's an example from the nc_basic dataset:

# Copy the schools point vector to a separate vector and add an attribute column
GRASS 7.2.1 (nc_basic_spm_grass7):~ > v.copy vect=schools,myschools
GRASS 7.2.1 (nc_basic_spm_grass7):~ > v.db.addcolumn myschools col="road_len double"

# Note that the roads layer has a column "SHAPE_LEN"
GRASS 7.2.1 (nc_basic_spm_grass7):~ > v.info -c roadsmajor
Displaying column types/names for database connection of layer <1>:
INTEGER|cat
DOUBLE PRECISION|MAJORRDS_
CHARACTER|ROAD_NAME
CHARACTER|MULTILANE
INTEGER|PROPYEAR
INTEGER|OBJECTID
DOUBLE PRECISION|SHAPE_LEN

# Now Use v.what.vect to copy the road lengths to the points vector
GRASS 7.2.1 (nc_basic_spm_grass7):~ > v.what.vect map=myschools query_map=roadsmajor query_col=SHAPE_LEN col=road_len dmax=9999

Note that I use a large dmax, since in this simple case the schools do not intersect the roads. In your case, since the connector lines DO intersect, you might be OK with the default dmax=0.0 (or maybe some small value)

# Here are the results
GRASS 7.2.1 (nc_basic_spm_grass7):~ > v.db.select myschools col=road_len | head
road_len
13067.640431
14943.396283
8395.042563
7899.466572
7899.466572
8105.732463
13151.265507
14943.396283
14943.396283

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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