4

I have two large CSV files, one that defines the location of each point as:

point lat lon attribute 1

And another that has data on what lines exist between them

point A point B attribute 2 attribute 3

Since the second CSV does not have lat/lon coordinates, I cannot map them. I've considered using LINESTRING, but the dataset is too big to manually compute the linestring between 2 points.

Is there any way to 'assign' the coordinates from the first CSV to the second?

2
  • I dont understand what you are asking. Can you add a sample of your csv files to your question?
    – BERA
    Sep 16 at 17:15
  • It's unclear if attribute1 is the same used in point A/B, but if it is, then yes, it's possible, though probably not necessary if you're constructing a line between them.
    – Vince
    Sep 17 at 14:57
3

If your points have unique IDs, which match between the CSV files, you may use join attributestable to add the coordinates from the first CSV to the second CSV twice. Then you can use make_line() to create the lines.

2
  • Thanks for the reply. Would I use QGIS's python console to do this?
    – lizard
    Sep 16 at 9:57
  • Nope, this is a tool, and an expression from the field calculator @lizard.
    – Erik
    Sep 16 at 10:31
2

Does your "point" from the first CSV and "point A" "point B" from the second CSV could be used for joining the two table ?

If so you should be able to join the table with coordinate to the second one. Do it two time, a first joint with "point A" and "point " to get lat A / lon A then join again but with "point B" and "point" to get lat B / lon B

As you now have a table with start and end point coordinate you could use geometry generator or the Geometry by expression tool to create your line

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