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
As you have Distance matrix
output, use its InputID
and TargetID
fields to build connecting lines.
Just open the Layer properties | Symbology
and select Geometry generator
.
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:
-
1Thank 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. Jul 2, 2018 at 10:11
-
With polygons, you can use the plugin "conefor" (you can convert point to polygon with a buffer and dont activ the option "edge distance")
With points, may be you can use the plugin "MMQGIS". You have here a tutorial that can help : hub line