How do I create a vector layer with a network of line segments drawn between every point in another vector layer? Basically, I am trying to create something similar to a hub/spoke network, except that instead of having a single hub and the other points are destinations, I would like every point to be treated as a hub with a direct connection to every other point.

I have managed to get the hub lines from one point to every other using the MMQGIS plugin "Hub Lines" module, but it seems that I would need to re-run it for each individual point. Is there a way to just do it all in one go? It may be worth noting that I don't need to know the distances between the points; I'm looking for the azimuths.

I'd prefer to do this in QGIS, but I've got some experience with SAGA and GRASS as well.


I think that it might be easiest to do with St_ShortestLine with PostGIS http://postgis.net/docs/ST_ShortestLine.html or with a similar ShortestLine function in Spatialite https://www.gaia-gis.it/gaia-sins/xmlBlob/spatialite-sql-latest.html.

You said you have only points but those functions can be used for other geometries as well. Here is an example with Spatialite.

SELECT shortestline(a.geometry,b.geometry) AS geometry, 
a.rowid AS start, b.rowid AS end 
FROM source_table a, source_table b 
WHERE a.rowid<b.rowid;

enter image description here

  • Thanks for the suggestion. Unfortunately I've never used PostGIS or Spatialite, and was daunted by the prospect of learning a new system. Fortunately, about an hour ago I stumbled across the FlowMapper plugin for QGIS. It does exactly what I had hoped for, though I have to create a file of dummy magnitude data for each point file (not too onerous). – Nick_W Apr 2 '15 at 0:36

My technique using the FlowMapper plugin to connect all the points with each other:

  1. In QGIS, save the point layer to a CSV file, checked "skip attribute creation", selected tab delimiter- only the coordinates should be exported. (I'll call this file A)
  2. Change the file suffix from .csv to .txt
  3. Open the file in a text editor and delete “X” and “Y” from the top (save and exit)
  4. Create a dummy magnitude file in excel/libreoffice calc/whatever. The dummy file must have as many rows and columns as there are points in the point layer (20x20, in my case)
  5. Save that file as a .csv with either space or tab delimiter. (I'll call this file B)
  6. Convert the .csv to a .txt
  7. In QGIS, in the FlowMapper plugin menu, select “Generate flow lines and nodes”.
  8. Select file A.txt for the node coordinates
  9. Select file B.txt for the flow magnitudes
  10. Select “gross” for “flow type”
  11. Enter a save file name/location for the output line shapefile
  12. Click “OK”.
    The resulting line layer has several attributes that aren't immediately useful to what I'm doing, so I deleted them, but they may be useful to others.

It's kind of a clunky workflow, but without learning PostGIS or Spatialite, it's the best I've managed to do (and it gets the exact result I was hoping for).

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.