Tuesday 4 June 2019

Joining attributes from nearest point in QGIS?


I have two layers with points, call them A and B, each with different attributes.



For each point in A I want to join all the attributes from the nearest point in B.


Ideally this would also include a field measuring the distance between both points.


I know how to so this in ArcGIS: right click layer A>joins and relates>joins, then join data based on spatial location and choose to join attributes from nearest point.


I could not find similar functionality in QGIS. Any pointers?



Answer



Using "Distance Matrix" you can calculate the nearest point. Make sure that both layers are in the same CRS! Then, you can load the results and use them to join table A and B.


In "Distance matrix" chose: "Linear distance matrix" and "use only the nearest k target points: 1"


enter image description here


Load the CSV using "Add Vector Layer" and join the layers in Layer A's layer properties - join tab.


enter image description here



And the result:


enter image description here


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...