I need to show in QGIS the a flow map of commuters in a municipality of Italy, Bari. In a CSV file I know the place they come from (a field called ORIG) and the place where they go (the field DEST) and the total number of them QGIS (TOTALE). In a shapefile I have the points with the coordinates; in this file the reference field is called SEZ. Since I'm a bit ignorant in Python and SQL, could you please tell me a simple way to write few lines that would let me show in the map with lines where they come from and where they go? I would also crate lines with different width depending on the total number of commuters (the field called TOTALE). I tried to create a virtual layer selecting, from the CSV, the fields I would like to show, then joining the CSV with the shapefile. But it didn't work. I think I'm not writing the code in the correct way. I saw there is a plug-in as well, Map Flow, but I need to create a matrix that is too long to write down.


1 Answer 1


I had to do something similar once and I used RT QSpider plugin.


  1. Install the plugin RT QSpider in Plugins > Manage and Install plugins

  2. Add the coordinates inside the attribute table of your shapefile of locations (if it is not already the case). To do so, you can use the tool in Vector > Geometry Tools > Export/Add geometry columns. It will create two new fields in the attribute table called xcoord and ycoord

  3. Open your csv file in QGIS using Layer > Add Layer > Add Delimited Text Layer

  4. Now you'll have to create 2 joins on your csv (one for the origin, and one for the destination). Right click on your csv in the Layer panel > Properties > Joins. Create the first join with the shapefile with geometry columns, join field should be SEZ and target field ORIG. Tick choose which fields are joined and select only xcoord and ycoord. Tick also Custom field name prefix and write origin_.

  5. Create a second join using the same method but this time for the destination (select the DEST field in target field and write dest_ as prefix).

If the joins worked, you should have in the attribute table of your csv 4 new fields (origin_xcoord, origin_ycoord, dest_xcoord and dest_ycoord).

  1. Select the csv in the Layer panel, and open the RT QSpider plugin in Plugins > RT QSpider > Table to vector converter.

  2. Choose Line as Output Geometry and select the right fields for the starting and end points (origin and destination X and Y). Click on OK and you'll have your lines. Don't forget to save the result as a proper shapefile.

Then, for the styling of the line, go to Symbology > Graduated. Select Method : Size and select the TOTALE field to vary the width of the line depending on the number of commuters.

Just realized that the plugin is not (yet?) available for QGIS 3.x ... this method will only work in QGIS 2.x

  • thank you for your answer. I tried what you said. A really nice method. So, I joined the fields you said and I had in my csv two fields with coordinates of both the origin and the destination. The first difficulty I met is that the RT QSpider plugin, in the modality Line, didn't read such coordinates. So I saved my csv (where THERE ARE the Orig_X Orig_Y Dest_X and Dest_Y) in another csv. With this other file I could run the Plug-in and insert the coordinates of origin and destination. But the shp so created didn't show anything. I have one explanation: it might be because in my case it is a re Commented Oct 6, 2019 at 14:09
  • Thanks a lot, at the end I was able to show what I wanted. I still have to refine the results, but it's a good start! Commented Oct 6, 2019 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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