When I use the NNjoin tool to compute the distance between points (from an CSV file) and a multilinestring (from a shapefile) the tool creates the new layer, but in this new layer it does not take over the attributes of the points in the CSV file and indicates that the distance is 0. Does anyone have any tips on how to make the NNjoin tool work?

Step by step, this is what I've done: 1. I have started a new project and added a shape file with multilinestrings and a CSV file and projected both in EPSG: 4326 WGS: 84. 2. I have saved the CSV file as a shape file 3. Then I've tried to use both the NNjoin tool and the "match attributes based on nearest" to create a new layer, both times the program would run but not calculate any of the distances, but only contain one row from the CSV file with a distance of 0 calculated.

The outcome I am hoping for is a new layer with the attributes from the CSV file with an added column with the distance between the points from the CSV file and the closest located part of the multiline string.

  • If you are using QGIS 3.8 or above you can use the native processing tool 'Join Attributes by nearest'. Maybe this fits your needs better.
    – MrXsquared
    Jun 4, 2020 at 13:41
  • Thanks I tried this tool as well. The problem remains, however, that it does excecute the request, but the new joint layer contains only the data categories, but no longer any of the values. Do you have any tips for this@MrXsquared?
    – Eline
    Jun 4, 2020 at 14:16
  • Uhm, for me it does take over the attributes of both layers. Can you include your exact steps taken in your question as well as the expected result on the basis of an example?
    – MrXsquared
    Jun 4, 2020 at 16:15
  • May I ask a) What are your layers CRS? , b)Have you tried exporting the csv point file as shp layer and use that instead? I usually us NNJoin with layers in a projected coordinate system (UTM for instance) and with shp files...as Mr MrXsquared, I use it a couple of days ago and I have attributes from both layers Jun 4, 2020 at 17:26
  • Thanks! To answer your questions a) I am projecting my layers in CRS: EPSG 4326 WGS 84 b) I have tried exporting the CSV point file to shp layer, so that does not work. Would you advice me to convert the file into a projected coordinate system, I am not sure how to choose which system to use @GerardoJimenez
    – Eline
    Jun 8, 2020 at 10:20


Your Answer

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