2

I have a CSV file with 2 columns with coordinates for the A side and 2 columns for the B side. I have several identifiers in other columns if needed.

I want to connect these with a line between A and B side. Approx 5500 rows.
Column AE identifier
BC & BD used for A side
BE & BF used for B side

enter image description here
Data example:

Longitude Latitude  Expr1_Longitud Expr_1_Latitude 
1295791.166 6469378.367 1292369 6474768 
1295791.166 6469378.367 1296158 6470702
  • Just make sure points which belong to each other have the same ID, then load everything into QGIS and use points to path/line. Also, a data-example could be helpful. – Erik Apr 2 at 9:23
  • Please edit your post rather than dumping lines of numbers in the comments which become hard to read. As to how QGIS can connect these points: Add a column which gives each row an ID, then load two points layers, one using the first two coordinates, one using the second pair of coordinates. Join these layers, then use points to lines. – Erik Apr 2 at 10:50
5

This is a good place to use a geometry generator as the render.

Simply add in the file as using one set of coordinates as a delimited text layer.

Then open up the layer properties and in the symbology.

Choose, Geometry Generator form the Symbol layer type and using the expression:

make_line( make_point("Longitude", "Latitude"),   make_point("Expr1_Longitud", "Expr_1_Latitude"))

Like so:

enter image description here

  • Works perfect! Many thanks! – Tobbe Apr 2 at 11:24
  • If i want to save the layer as a kml with the lines how do i do that? – Tobbe Apr 3 at 8:38
  • See answer by @JGH – HeikkiVesanto Apr 3 at 9:16
3

If you need the line for analysis (and not just for display), you can use a virtual layer.

The expression is very similar to the one provided by @HeikkiVesanto

go the menu layer / add layer / add - edit virtual layer then insert the query

SELECT referenceID, ST_make_line( ST_make_point("Longitude", "Latitude"), ST_make_point("Expr1_Longitud", "Expr_1_Latitude")) as geometry

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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