1

I am trying to run NNjoin plugin on a point layer (one layer, so a selfjoin) to find nearest neighbour, but the joined layer it produces has 0 features in it. The original points layer has 32000 features. I tried to use distance matrix which worked, but I want to retain the original attributes, which is the benefit of NNjoin. Does anyone know why this might be? I don't get any error messages. I am using EPSG:27700 if that is important.

2
  • To clarify, is your desired output a shapefile with the original features that also contains a field with the ID of the nearest neighbor from the same set of features?
    – Kartograaf
    Commented Aug 25, 2022 at 19:45
  • yes, as you usually would with nnjoin. I have done it before with other data so not sure why it isn't working now.
    – Eebee112
    Commented Aug 25, 2022 at 19:58

1 Answer 1

0

You can just run NN join directly on the layer by setting both the input and join fields to that layer. The output will consist of the original geometry with new fields in the attribute table that relate each feature to it's nearest neighbor, including the distance in map unites (meters in your case).

Original data:

enter image description here

NNJoin interface:

enter image description here

Result:

enter image description here

12
  • Hi, this is what I have done, but the attribute table is completely empty. I have added photos
    – Eebee112
    Commented Aug 25, 2022 at 20:02
  • Can you try to run the tool on a small subset of your points? I have a feeling the issue could be with the number of features in your layer and the less than optimal memory allocation by the NNJoin tool.
    – Kartograaf
    Commented Aug 25, 2022 at 20:08
  • Tried running nnjoin on a sample of 300 of the points, and the same thing happened where the joined layer was empty
    – Eebee112
    Commented Aug 25, 2022 at 20:11
  • 1
    Can you share your data?
    – Kartograaf
    Commented Aug 25, 2022 at 20:27
  • 1
    OK, try this then, create a new point shapefile layer using EPSG:3857, then add new geometries to that layer that mimic the locations of 5 or 10 of your points, then save the layer and try running the tool on the new layer in the same way as above. Be sure to label the ID fields with unique integers as you create them or after the fact.
    – Kartograaf
    Commented Aug 25, 2022 at 20:34

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.