This article explains the presentation of flows on a map, using the FlowMapper plugin. For this demonstration, data on commuting patterns between 40 regions are used (from Statistics Netherlands).
Preparing the data
After the plugin is installed in the usual way, the manual can be found in the folder C:\Users\{username}\.qgis2\python\plugins\FlowMapper2_documentation.Three text files are required, with node coördinates, node names and a flow matrix. Three points must be stressed that are not mentioned in the manual. 1) The plugin does not work well with numbers with decimals. That can be solved by multiplying the numbers by (e.g.) 1000 and then round them. 2) As delimiters, both spaces and tabs may be used. The latter is especially useful when pasting data into a text file from Excel. 3) The node names should not contain spaces, because these are handled as delimiters. Replace them with underscores.
Generate shapefiles with FlowMapper
The next step is to generate two shapefiles, one with nodes and one with lines. In the Plugin menu select “FlowMapper” / “Generate flow lines and nodes”. Now you can fill in the file names and other specifications.
The first set of options concerns the shape files to be generated. The last set of options is about the presentation of the flows and nodes from the generated shapefiles. The formatting of lines and nodes can also be done with the regular QGIS-methods. Moreover, post-processing is often necessary, in order to limit the number lines displayed. That’s the topic of the next section.
Less lines by using filter
If you open the shapefiles with flows and nodes in a new project, this results in a huge jumble of lines. In this case 1,600 (40 x 40).
The number of lines displayed can be reduced by using a filter. In the layer list, right click on the layer with lines and select “Filter …”. Now you can select flows, based on the size, the region of origin, or the region of destination. The following illustration shows a combination of all three criteria.
The result of this filter is, that only flows to and from the selected region, larger than the specified value, are shown.
Settings for lines, markers and labels
If “Net” or “Gross” was selected in the Flow Mapper plugin, the layout of the lines is fairly simple. The challenge is greater if the shapefile contains flows in two directions. Then it is important to distinguish the lines, markers and labels by direction. Here are four screenshots. The first shows how the lines can be shifted relative to each other. The next two show how markers can be added, in the right place and with the right direction. The fourth screenshot demonstrates the positioning of the labels.
Result
The following two maps show the result of the above settings.
nice !
Fraai, ik deed dit tot nu handmatig, dit gaat een stuk soepeler!
Bij het downloaden van deze plug-in krijg ik de reactie:
Plug-in werkt niet. Python meldt: No module named ogr.
Wat kan ik hieraan doen?
Dat heeft wellicht te maken met de QGIS-versie die je gebruikt. Misschien kan de maker van de plugin je verder helpen. Zie: http://95.9.195.180/.
De maker van de plugin gaf aan dat de FlowMapper wel in versie 2.4 werkt en dat klopt! Blijkbaar een bug in versie 2.6.1.
Ik krijg een foutmelding bij het inlezen van de COROP-middelpunten coördinaten.txt file. Heeft dit te maken met de komma in de (eerste) X-coördinaat van Oost-Groningen: 264101,2969?
Er is een fout opgetreden bij het uitvoeren van Python code:
Traceback (most recent call last):
File “C:/Users/Gerlof Rienstra/.qgis2/python/plugins\FlowMapper\flowmapper.py”, line 2656, in run
flowpyv07.shapefilemaker(FlowType,CreateShpNodes,IncludeNodeNames,str(SaveDirectory), str(SaveShpName),str(SaveShpNameNodes),str(InputMatrixName),str(InputNodesName),str(InputNodeNamesName),str(combotext))
File “C:/Users/Gerlof Rienstra/.qgis2/python/plugins\FlowMapper\flowpyv07.py”, line 72, in shapefilemaker
onevalue2 = float(separatestrings2[ptcolumns])
ValueError: invalid literal for float(): 264101,2969