Creating flow maps in QGIS

Although it isn't a GIS Tool, this is something you could use Gephi for. Especially if you want it to look like your illustration. Straight lines, no problem. Curves are more challenging.

Gephi is for network analysis and plotting. It's typically used for things like social network analysis (e.g. analysing Facebook or Twitter networks)

This example shows a screenshot - this is a road network, taken from OpenStreetMap. Nodes are coloured by Centrality.

enter image description here

If you install the GeoLayout plugin for Gephi you can force nodes to stick to (lon,lat) or other projected coordinates, which makes it suitable for Geo visualisations.

In your case,

  • your nodes are locations, and
  • edge weights are traffic between those locations

Edges can be one-directional or bi-directional.

The easiest way is to create a couple of CSV tables in QGIS (or programatically). This will probably be easier to do if you have your data in a database rather than a shapefile.

Create a node table

  • assign a unique Id to each node (e.g. Town_A)
  • add X and Y values alongside the node name (and export to CSV using Geometry AS_XY)

Create an edge table

Add another table linking node A to node B together with weighting value, to form your edges table. You'd need one row for each response, with a count of the number of times someone makes a journey from A to B e.g.

From, To, Count
Town_A, Volcano_A, 1
Town_A, Town_B, 1
Beach_A, Beach_B, 1
.. etc..
Beach_B, Town_A, 2
Beach_B, Beach_A, 2

Then import these into Gephi as CSV

On the analysis side, you could also get added information on centrality, betweenness, clustering and other metrics.

(You can get some of these from GRASS; however, that doesn't address the rendering).


For a pure QGIS solution, check https://anitagraser.com/2019/05/04/flow-maps-in-qgis-no-plugins-needed/

The key is to create a virtual layer: Virtual Layers: Layer | Add Layer | Add/Edit Virtual Layer

SELECT StartID, DestID, Weight, 
   make_line(a.geometry, b.geometry)
FROM edges
JOIN nodes a ON edges.StartID = a.ID
JOIN nodes b ON edges.DestID = b.ID
WHERE a.ID != b.ID 

The resulting flow lines can then be style with the built-in arrow renderer:

enter image description here

Tags:

Qgis

Flow Map