Saturday, 15 August 2015

Problem with Distance Matrix in Qgis 2.83


I want to calculate the distance of archaeological sites to the nearest river. Following this question Calculating minimum distance between points and polygons in QGIS? I extracted the nodes of the rivers layer and assigned a unique ID to each resulting point. I have a layer of almost 90,000 points/nodes. My archaeological sites layer has only 42 sites. Both layers are in EPSG 32615 (UTM 15N WGS84). I performed the Distance Matrix with the following settings:


Input Layer: Sites


Unique ID input layer: Site ID



Target Layer: nodes


Target unique ID: nodes id


Use only the nearest (k) target points" as 1


Now the problem, the resulting distance matrix states that all the sites have the same neighbor and are at the same distance of it:


enter image description here


This is not the only weird thing. The resulting distance should be in meters, since my layers are in EPSG 32615, but the resulting distance is almost two million meters!!. With Qgis manual measuring tool the distance between the “master node” to the nearest sites is almost 25,000 meters, and to the furthest one about 56,000 meters.


I wonder if someone could give me a hint on what I am doing wrong.


Ps. I also tried MMqgis hub distance tool, but some of the resulting lines do not lie in a line node, enter image description here


and the calculated distance is the same for every line


enter image description here




Answer



Distance matrix in QGIS works on two point datasets, meaning that each line in your river dataset will be converted to a (representative) point before calculating the distance / finding the nearest neighbour.


If you need to join a point dataset and a line dataset based on "true" shortest distances between points and lines, you should use v.distance (GRASS) or the NNJoin QGIS plugin (QGIS).


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...