6

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?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Nov 10, 2014 at 10:05

2 Answers 2

4

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...

answered Nov 10, 2014 at 11:44
1
  • I chose this as the most intuitive and convinient method. Thanks for both of them :) Commented Nov 10, 2014 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.

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.