6

I would like to use the distance matrix tool (or a similar function) to look at distances between sites (displayed as point data) and large rivers (displayed as linear).

I have been following this nearest neighbour tutorial until now http://www.qgistutorials.com/en/docs/nearest_neighbor_analysis.html

But the distance matrix tool only allows for point data. Apart from the fact my input layer (European rivers) is linear, the initial aim of this research is pretty basic. I want to find the mean distance between my sites and major rivers (later i want to examine the results in terms of travel times using slope data but that's a diffrent question I guess).

Is there a precedent for this kind of research or am I on the wrong track entirely? Am using QGIS 2.16.

  • 3
    You could try using the GRASS tool v.distance from Processing Toolbox > GRASS commands > Vector > v.distance. This calculates the nearest distance from one 'element' to another in two different layers. – Joseph Aug 15 '16 at 11:21
  • 2
    What I did was to extract the nodes of the linear/polygon features, then assign a unique id to each node. A little bit cumbersome but it does work – Gerardo Jimenez Aug 15 '16 at 14:46
  • @Joseph I've been trying the v.distance and v.distancetoandfr tools. Been having trouble with the configuration of both, as each time i try and run the algorithm i get the dialogue telling me that the new layer "distance" cannot be created. I've played around a bit with the settings but it still comes to this. My layers are on 2 different CRS's. Have tried with both csv and shp as the origanal input file – stacy Aug 16 '16 at 11:57
  • checked whether the tool didnt function due to the crs by using shapefiles with the same crs. The operation runs without any apparent problems but leaves me with a blank shapefile, the attribute table has only "cat" as a field and nothing else – stacy Aug 16 '16 at 12:10
  • Can't seem to replicate your issue as the tool seems to work fine for me. Have you tried the method suggested by @GerardoJimenez? Perhaps you could upload your shapefiles to a public server so that others could test it? – Joseph Aug 16 '16 at 14:37
5

I did have the same the same research question as you. I wanted to calculate the distance from archaeological sites to rivers. I did have access to a hydrological layer by INEGI. I did have rivers as lines and as polygons. This is what I did. First I converted the polygons to lines using vector/ geometry tools/polygon to lines. Now I did have all my rivers as lines. I merged both layers using vector/data management tools / merge shapefiles to one.

enter image description here

Now with just one line layer I extracted the nodes of this layer with vector/ geometry tools/extract nodes. You can see the result. One piece of advice. For some reason all my nodes were extracted as multipoint, so I used vector geometry tools/ multipart to single parts to have my nodes as individual nodes (look at this Problem with Distance Matrix in Qgis 2.83).

enter image description here

Assigning an individual identifier is easy . Using the field calculator, you can use under variables the row_number function. This will add a consecutive ID to each node.

enter image description here

Now you can use the distance matrix tools as described in the link you mention. Here are my results following the same tutorial

enter image description here

enter image description here

As you can see, Is not a one step procedure, but It did work.

Hope it help you

  • muchas gracias, my research is archaeological too, this solves my problem nicely – stacy Aug 16 '16 at 18:51
  • Using the NNJoin QGIS plugin would have saved you a lot of work. It works with points, lines and polygons. – Håvard Tveite May 29 '18 at 23:56
1

The NNJoin QGIS plugin will calculate the distance to the nearest river for each point. v.distance does the same thing and is a good alternative (as suggested in one of the comments), but it has issues when run from QGIS Processing.

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.