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 Answers 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– Manos C2014年11月10日 14:48:09 +00:00Commented Nov 10, 2014 at 14:48
With not that hard adjusting you should be able to use Processing / Toolbox... QGIS algorithms / Vector creation tools / Points to path
Points to path
the point layer must be exported to csv including id of points and coordinates x,y
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
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.
every line in new csv must contain Path_ID (Group), Order (starting=1 / ending=2),X, Y
load CSV through Add delimited text layer and create new point layer with all starting and ending points
run on this table the above mentioned tool Points to Path
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– Manos C2014年11月10日 10:32:39 +00:00Commented 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.Miro– Miro2014年11月10日 10:44:12 +00:00Commented Nov 10, 2014 at 10:44
-
I added 7 steps which describes the complete process to make it even more clear.Miro– Miro2014年11月10日 11:37:29 +00:00Commented Nov 10, 2014 at 11:37