I have a series of Output Area centroids and I want to create a matrix of lines between each point (every point connected to every point), which is effectively what the distance matrix tool does (I think). But I also need the line geometry for visualisation purposes. Can anyone tell me how to do this?

2 Answers 2


As you have Distance matrix output, use its InputID and TargetID fields to build connecting lines.

enter image description here

Just open the Layer properties | Symbology and select Geometry generator.

enter image description here

If your original point layer name is points and it has id field (the one you used to create the Distance matrix), the expression would be:

make_line(geometry(get_feature('points', 'id', "InputID")), 
          geometry(get_feature('points', 'id', "TargetID")))

It will give you these connecting lines:

enter image description here

  • 1
    Thank you, this was very helpful. In the end I used the 'Geometry by Expression' tool to generate a permanent output, using the code you provided.
    – AJIKenyon
    Commented Jul 2, 2018 at 10:11
  • 1
    It does not seem to work on my QGIS 3.12.2
    – Arkeen
    Commented Jun 17, 2020 at 11:49

With polygons, you can use the plugin "conefor" (you can convert point to polygon with a buffer and dont activ the option "edge distance")

enter image description here

With points, may be you can use the plugin "MMQGIS". You have here a tutorial that can help : hub line

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.