I have a points layer and polygons layer with attributes I want to join for each point. Not all points are exactly within a polygon, so I'm looking for a way to join attributes based on nearest polygon (so that if a point is located within a polygon it will just get its attributes). I've tried using the NNJoin plugin, but I've noticed that for lots of points that are located within a polygon, it will joing attributes of a different polygon.

1 Answer 1


Try splitting your point data in two. First part would be the points that fall within a polygon and the second part would be points falling outside polygons. For the first part, perform a regular spatial join, and for the second part, use the NNJoin plugin. You can later merge the two resulting point layers into one. This way you can avoid the plugin performing an incorrect join on some of the points that fall within a polygon.

In order to select points that fall within the polygon layer, use the Spatial Query plugin (now a core QGIS plugin), then save the selection as a new layer. Invert the selection and save it as the second layer and perform the join using the NNJoin plugin.

Note that I have never used the NNJoin plugin.

  • I think that NNJoin doesn't do a very good job (tried your method, which was a good idea, but still got weid results). So I was hoping for an alternative way to join attributes of a polygon to a point based on nearest polygon.
    – nadavb
    Commented Feb 26, 2017 at 12:19

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.