I am using QGIS 2.13 and a layer with hundreds of points. I need to calculate the distance to the nearest point... in the same layer. I tried the distance matrix but I get 0m since the "closest" point is the origin point.

The idea is calculate the average distance, std deviation, etc. and create a graph/histogram with these data to see how the distribution looks like.

Does anybody know how to calculate the distance to the nearest point in the same layer avoiding the origin point?

2 Answers 2


There are a couple of versions of this tool. If you use the one from the Processing Toolbox, it will contain distances within the origin points. Instead, use the Distance Matrix tool from the menubar:

Vector > Analysis Tools > Distance Matrix

This version ignores calculating the distance of the origin points with itself.


The QGIS NNJoin Plugin supports joining a layer to itself. It calculates the distance to the nearest neighbour (excluding the feature itself) and adds the distance to the result layer. The result layer will also contain the attributes of both of the features.

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.