0

This question already has an answer here:

I am new to QGIS. I am looking for any plugin or any manual method in QGIS for finding minimum distance (perpendicular distance) from a point which is part of one shapefile to nearest line among many lines which is part of another shapefile. MMQGIS is not useful for this purpose. I used v.net.connect command.

I am getting minimum distance (perpendicular distance) from points which are part of one shapefile to nearest line among many lines which is part of another shapefile, but there is one problem. I am not identifying from the attribute table which distance belongs to which line.

In the attribute table, there 32 distance values for 32 points w.r.t nearest line. Is there any method to identify which distance value is belong to which nearest line? I want to identify the line identity in attribute table w.r.t distance value

marked as duplicate by whyzar, Vince, Andre Silva, Community Feb 22 '17 at 2:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

Iit's not clear what you are doing with v.net.connectivity, but the correct way to get distances from points to lines in GRASS is with v.distance. If you have two maps in GRASS: "points" and "polys", then

# Add a column to the points attribute table for the distance
v.db.addcolumn points column="dist DOUBLE PRECISION"
# Calculate distances
v.distance from=points to=polys output=connectors upload=dist column=dist 

You can additionally get the "cat" (category) value of the nearest line feature for each point as follows:

# add two columns to the points attribute table
v.db.addcolumn points column="dist DOUBLE PRECISION"
v.db.addcolumn points column="line_cat INTEGER"
# Now get both the distance and line cat value in one go:
v.distance from=points to=polys output=connectors upload=dist,line_cat column=dist,cat

For more details, have a look at the man page

  • Thanks Michael for your reply. I tried method suggested by you. But I am not getting desired result. I am using QGIS with Grass. I have loaded vector map of my both layers ( points and lines) using v.in.ogr in QGIS. Then I have added column in point layer using v.db.addcolumn . Then I have used v.distance for final result. However attribute table of point file , dist column is showing null value and output connector file has only one column in attribute table which is CAT. I am not getting minimum distance from respective points. – Jitendra Feb 20 '17 at 12:54
  • I want relationship like point , line and minimum distance in attribute table. Points should have unique identity w.r.t line and minimum distance. May be more than one point are near to single line. I need minimum distance from points to lines with following relationship: Point ID. Line ID. Min Distance. 0. 3. 43 mtrs. ; 1. 3. 100 mtrs; 5. 10. 500 mtrs. ; 30. 10. 5 mtrs – Jitendra Feb 20 '17 at 13:02
  • I'm not sure what the problem is. Are both layers in the same coordinate system? Are you getting any errors when the module runs? – Micha Feb 21 '17 at 17:50
  • Yes both the layers are in same coordinate system. Every command is working fine. I am getting distance in attribute table of output layer (connector) using field calculator ( length function). But I am not able to corelate distance field with respective point and line. Means I am getting 32 distance value from 32 points in output layer but for example distance at CAT 16 in attribute table of output file , i am not able to identify this distance is between which point and line. Is there any method to corelate distance , point and line ? – Jitendra Feb 21 '17 at 18:42
  • I've editted the answer above. Have a look, maybe it will help you along. – Micha Feb 21 '17 at 21:42

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