At 2.18.16, the QGIS tool Distance Matrix computes pairwise distances between all points, either within one layer or between two layers. Here's a screenshot for a single layer. Note that only points (highlighted) are allowed:

enter image description here

I'm looking for a tool or plugin that extends that Distance Matrix concept to include lines and polygons. For example, suppose you had a single polygon layer depicting lakes and you wanted to know the distance between each lake and every other lake in that same layer (shoreline to shoreline). Similarly, consider a situation with two layers, one of them point and the other polygon, wherein you needed to know the pairwise distances between every point and every polygon outline.

I considered the NNJoin tool, because it accepts points, lines and polygons. Unfortunately it does not meet my need because it computes only the single shortest distance for each feature, whereas I'm interested in all distances.

A review of the Processing Toolbox did not turn up anything useful.

I'm considering a workaround that deconstructs lines and/or polygons to their constituent vertices, converts the vertices to points, applies the Distance Matrix tool to those points, records the pairwise point distances and then joins those to the original line/point layers.

That workaround seems complex, so before I begin, I'm asking for help: Is there an easier way to calculate all pairwise distances between features - point, line or polygon - either within a layer or between layers?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.