QGIS Polyline Creation – Drawing Lines Between Pair of Two Points with Coordinates

coordinatescsvpointpolyline-creationqgis

I'm using QGIS 3.18. For my thesis I use coordinates of starting points and destination points. So far I uploaded these coordinates into my project which worked without any problems. The CSV-file contains 4 columns: lat & long for both.

I have two layers – one for the starting points and the other one for the destination points. Now, I want to connect those points using lines but unfortunately I cannot find any plugin with suits those needs.

Best Answer

You could use the "Geometry by Expression" tool from the processing toolbox.

As input layer use your original CSV with all coordinate column, choose line as Output geometry type and use an expression like :

make_line( make_point( X_start , Y_start) , make_point( X_dest , Y_dest))

(replace the X_start , Y_start, X_dest and Y_dest by the actual field name of the respective coordinate)

This will create a new line layer with line joining your points.

If you just want to symbolize the line you could use the same expression in the geometry generator (in this case the line will only be displayed if the point is displayed, so if you set the geometry generator on starting point and zoom to the destination point enough to get the stating point out of frame the line will disappear)