5

I have two CSV data sets: points CSV and links CSV.
I have easily generated nodes in QGIS but I do not know how to make lines between the points.
There must be an applicable tutorial or previous post - please help, here are the details:

  1. point data CSV example, first ten points
"Manhole_ID","Manhole_No","Coord1","Coord2","Cover_Level","Inflow","No_Of_Pipes","Pipe1","Pipe2","Pipe3","Pipe4","Population"
"C15D","MHA1",98922.34,2872997.45,1394.85,100.00,1,1,0,0,0,0
"C15C","MHA2",98915.48,2872937.84,1392.28,100.00,2,1,2,0,0,0
"C158","MHA3",98910.56,2872895.19,1390.41,100.00,2,2,3,0,0,0
"C151","MHA4",98905.44,2872850.74,1388.69,0.00,3,3,4,21,0,0
"C150","MHA5",98894.93,2872759.60,1384.62,20.00,2,4,5,0,0,0
"C14F","MHA6",98883.49,2872660.26,1379.75,0.00,2,5,6,0,0,0
"C14C","MHA7",98872.04,2872560.92,1373.89,0.00,2,6,7,0,0,0
"C148","MHA8",98865.84,2872507.10,1370.33,20.00,2,7,8,0,0,0
"C145","MHA9",98865.28,2872502.26,1370.04,0.00,2,8,9,0,0,0
"C142","MHA10",98851.69,2872491.85,1369.28,0.00,3,9,10,24,0,0
  1. line data CSV example
"PIPE_ID","Pipe_No","Upstream_MH","Up_MH_Invert","Downstream_MH","Down_MH_Invert"
AEFB,1,MHA1,1393.55,MHA2,1390.99
AEFF,2,MHA2,1390.99,MHA3,1389.12
ADE4,3,MHA3,1389.12,MHA4,1387.4
ADE5,4,MHA4,1387.4,MHA5,1383.12
ADE6,5,MHA5,1383.12,MHA6,1378.25
ADE7,6,MHA6,1378.25,MHA7,1372.39
ADE8,7,MHA7,1372.39,MHA8,1368.83
ADE9,8,MHA8,1368.83,MHA9,1368.54
C128,9,MHA9,1368.54,MHA10,1367.27

The lines need to use the node names upstream_mh = manhole_no and downstream_mh = manhole_no to draw line features

1

3 Answers 3

6

There is a tool in QGIS called "Points to Paths", you can find it under
Processing-->Toolbox-->QGIS geoalgorithms --> Vector creation.

You will need to preprocess your data though. This tool needs a Group field, based on which it knows which points belong to one line.

So this is what you need to do:
In the points.csv duplicate your points, with the exception of the first and last point. Add a field called "Pipe_No" and fill this field with the pipe nr. Eg:

Manhole_ID,Manhole_No,Coord1,Coord2,Cover_Level,Inflow,No_Of_Pipes,Pipe1,Pipe2,Pipe3,Pipe4,Population,Pipe_No
C15D,MHA1,98922.34,2872997.45,1394.85,100,1,1,0,0,0,0,1
C15C,MHA2,98915.48,2872937.84,1392.28,100,2,1,2,0,0,0,1
C15C,MHA2,98915.48,2872937.84,1392.28,100,2,1,2,0,0,0,2
C158,MHA3,98910.56,2872895.19,1390.41,100,2,2,3,0,0,0,2
C158,MHA3,98910.56,2872895.19,1390.41,100,2,2,3,0,0,0,3
C151,MHA4,98905.44,2872850.74,1388.69,0,3,3,4,21,0,0,3
C151,MHA4,98905.44,2872850.74,1388.69,0,3,3,4,21,0,0,4
C150,MHA5,98894.93,2872759.6,1384.62,20,2,4,5,0,0,0,4
C150,MHA5,98894.93,2872759.6,1384.62,20,2,4,5,0,0,0,5
C14F,MHA6,98883.49,2872660.26,1379.75,0,2,5,6,0,0,0,5
C14F,MHA6,98883.49,2872660.26,1379.75,0,2,5,6,0,0,0,6
C14C,MHA7,98872.04,2872560.92,1373.89,0,2,6,7,0,0,0,6
C14C,MHA7,98872.04,2872560.92,1373.89,0,2,6,7,0,0,0,7
C148,MHA8,98865.84,2872507.1,1370.33,20,2,7,8,0,0,0,7
C148,MHA8,98865.84,2872507.1,1370.33,20,2,7,8,0,0,0,8
C145,MHA9,98865.28,2872502.26,1370.04,0,2,8,9,0,0,0,8
C145,MHA9,98865.28,2872502.26,1370.04,0,2,8,9,0,0,0,9
C142,MHA10,98851.69,2872491.85,1369.28,0,3,9,10,24,0,0,9

If your dataset is too big, work with excel or with a database.

Load this into QGIS, start the Points to Path tool and fill the fields like this out: Points to Path

This creates a line layer of the point pairs.
Now you need to join this layer with your lines.csv
To do this:
1. Import the lines.csv but only the attribute table
2. Rightclick on your lines layer --> properties --> joins --> +
3. Choose the "group" field from your lines layer, and "Pipe_No" from the lines.csv to join the data.
For the joining part here is a good tutorial.

4

Maybe more simple if I got it right. If MHA1 has to be connected to MHA2 that has to be connected to MHA3 and so on in this order, then just add a column grp with a 1 in all fields for example (or whatever you want) it is just to use an aggregation in :

select makeline(p.geometry) as geom, p.grp from thepoints p
group by p.grp

enter image description here

was it you wanted ?

0

Late, but for future help, if you have starting and ending points coordinates (joining the points table to the links table would do the job): Using xy to lines tool creates lines between the points. xy to Line

Tool parameters

Your Answer

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

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