I have the following situation:

I have two CSV files: One file lists all nodes and their longitude and latitude in the following manner with the following columns:

ID Name Longitude Latitude

No importing these points into QGIS is no problem. However, I would now like to import a second CSV to connect these points. That CSV has the following columns

Connection ID From To To To To To

I give each connection an ID and then under "From" and "To" I put the "ID" that corresponds to the nodes in the first CSV files. Importantly, these connections usually have more than two points (thus the several "To" columns).

Is there an easy way of creating these connections (lines) between the points in the first CSV? And is it possible to do it with the second CSV files I am using, most importantly in terms of having multiple points for each connection?

I know that certain plugins ("PointstoPaths") can be used for this, but I am using QGIS Firenze and have not been able to find a suitable plugin that works with this version.

  • 3
    From a ease of handling perspective you would be better with connection table |id|from|to|. At the very least all field names need to be unique such as ||Connection ID|From|To1|To2|To3|To4| Are all "to?" always non null? One feature per 'connection id' or just one feature per 'from' 'to?'? Apr 4, 2023 at 18:53
  • Okay thanks. I hope I understand what you mean: No, in certain cases "to" is empty. Can I ask what you mean by "feature"? Apr 5, 2023 at 8:15
  • Does the answer in this question help: gis.stackexchange.com/questions/141078/… ?
    – e-shirt
    Apr 5, 2023 at 9:22
  • A tldr for what a qgis feature is, might be one row of a layer. The linked stack exchange has a decent answer. Apr 5, 2023 at 17:50
  • Points to path is available in QGIS 3.28 Firenze, its not a plugin: Menu Processing > Toolbox > Points to path: docs.qgis.org/3.28/en/docs/user_manual/processing_algs/qgis/… You must make sure you load the CSV in a way to create points
    – Babel
    Apr 9, 2023 at 15:16

1 Answer 1


I created a CSV file, with columns with the same name and then I load it in QGIS. What QGIS does is to add a consecutive suffix separated by an underscore in the repeated fields (e.j. To, To_1, To_2, ...). So every "To" field name has the form To_#.

Try this, open the "Geometry by expression" tool, set the output geometry type to the line and use this expression. Remember to change the node layer name/id in the expression.

            NOT attribute(@element) IS NULL
                    'Point layer name/id', --replace here with your values
                    'Point layer name/id', --replace here with your values

Then use the "Multipart to singleparts" tool to separate each different line, because the geometry generator will generate a multipart geometry in this case.

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.