4

My question is probably a basic QGIS question but I could not find something that would work for me.

I have a file of the following format:

CSV File Format

where each from/to is a point that is already inserted to QGIS (point layer)

QGIS with points

How do I insert the lines' data from the CSV file to QGIS?

2

In previous answer I completely forget to check plugins first which you should always do because there are really many good ones and for this particular case you want to use:

PointConnector

Creating lines between points following a from-to list

You can install it through Plugins / Manage and install Plugins...

  • I chose this as the most intuitive and convinient method. Thanks for both of them :) – Manos C Nov 10 '14 at 14:48
1

With not that hard adjusting you should be able to use Processing / Toolbox... QGIS algorithms / Vector creation tools / Points to path

Points to path

  1. the point layer must be exported to csv including id of points and coordinates x,y

  2. the csv with FROM / TO must have some Path_ID (Group) for every future path through which the attribute COST or others will be linked, and after that loaded into QGIS

  3. there must be created copy of your csv table which must be reformatted in the way that every line gets split into two: one line for starting point, one line for ending point.

  4. every line in new csv must contain Path_ID (Group), Order (starting=1 / ending=2),X, Y

  5. load CSV through Add delimited text layer and create new point layer with all starting and ending points

  6. run on this table the above mentioned tool Points to Path

  7. you should get paths with Path_ID (Group) through which you can now join other data like "COST" by using join in properties of the point layer and save as new layer

Example of points table and final paths:

points to paths example

I am sure it is possible to do it way easier with python script but well, unfortunately I am not that far yet with Python in QGIS.

  • Could you please elaborate a bit more (or point to a link) on the way that those adjustments should take place? – Manos C Nov 10 '14 at 10:32
  • Elaborated, hope that helps, it is really only about preparing / adjusting csv to format which can be processed by that tool. – Miro Nov 10 '14 at 10:44
  • I added 7 steps which describes the complete process to make it even more clear. – Miro Nov 10 '14 at 11:37

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.