3

I have used the Vector -> Analysis Tools -> Distance matrix to merge two datasets by the closest points.

But in my output csv file, the points that match exactly, or that has 0 metres between them are left out. However, I need these to be included in my analysis. How can I solve it?

What I want is to get all my rows or points included in the output file. both the ones that have some distance between them (Im interested in the nearest, so Ive set the "Use only the nearest (k) target points" to 1), and the ones that match exactly (or are as close as 0 metres)...

My target file looks like this with the unique ID field being the first column.

776 20  21  Sommer  15  362090  6448220 91,17288005 81,29255262
777 20  21  Sommer  16  362080  6448220 82,0068365  89,23947222
778 20  21  Sommer  17  362070  6448220 72,84079294 93,09493861
779 20  21  Sommer  18  362060  6448220 63,67474938 87,23483922 
780 20  21  Sommer  19  362050  6448220 54,50154742 82,17765362 
781 20  21  Sommer  20  362040  6448220 45,32403426 77,6562944  
782 20  21  Sommer  21  362030  6448220 36,14652111 73,65212869  

And my input file looks like this. The unique Id field is here the last column.

Year    UTM-¿st UTM-nordID  Art     vei         turbin              unique ID field
2011    361452  6448500 20  Hjort   75,78870308 183,814654  H   175-200 149
2011    361322  6448500 20  Hjort   30,24121334 88,0259451  D   75-100  150
2011    362043  6448230 25  Hjort   70,09615368 533,61694   NA  >200    151
2011    362070  6448220 25  Hjort   93,09493861 560,4653704 NA  >200    152
2011    362152  6448220 25  Hjort   40,42562935 624,70644   NA  >200    153
2011    362177  6448220 25  Hjort   31,05429277 645,0934399 NA  >200    154
2011    362191  6448219 25  Hjort   27,17585338 657,2094756 NA  >200    155
2011    362194  6448218 25  Hjort   26,84745014 660,2549379 NA  >200    156
2011    362208  6448219 25  Hjort   20,19118365 671,3551471 NA  >200    157

The datasets consists of approx 1200 and 650 rows.

EDIT

I solved this by using NNjoin instead of the distance matrix tool. But if anyone has an answer to the question of how to solve this using the distance matrix tool, please let me know!

1
  • 1
    Although your solution was a workaround to your problem, you should still post it as an answer and remove it from your question =)
    – Joseph
    Commented Feb 3, 2016 at 10:12

1 Answer 1

2

Try using the same tool but from the Processing Toolbox:

Processing Toolbox > QGIS geoalgorithms > Vector analysis tools > Distance matrix

This version includes distances at 0 m. The first image shows the results of the Distance matrix tool from the Processing Toolbox:

Processing Toolbox Distance matrix

This second image shows the results of the Distance matrix tool from the toolbar (same method you used), opened in Excel and sorted in terms of distance from smallest to largest:

Toolbar Distance matrix

No 0 m results were recorded. So try the one from the Processing Toolbox.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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