Generating line segments between all points using QGIS

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


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).