2

I work for a survey company and we convert our raw survey data into a GIS format our clients can use and have used MapInfo in the past to achieve basic shapes our clients can use.

I start with 2 CSV files which simply have the attribute data and X, Y values for "Pits"(Points) and "Pipes" (Lines).

The Pits geometry works fine and is just created from the X, Y values, it's when I try to create "Pipes" (line) geometry which has the attribute data attached that I'm having issues.

The Pipes CSV contains 4 Columns labelled US_X, DS_Y, US_X, US_Y these refer to the X & Y of the upstream and downstream. Previously in MapInfo we would use a "CreateLine" command that could reference these 4 Columns and create the linework which also had the attribute data attached.

My attempts to do this in QGIS have involved bringing the CSV in via Data Source Manager -> Delimited Text and then lots of variations to attempt to create the geometry start from here. My closest attempt has been to choose 1 pair of the X,Y co-ordinates for the geometry definition and then create geometry from symbology->geometry generator using an expression that uses "Make_Line" stating the initial points I chose and then referring to the remaining co-ordinates to give it the other end. This worked but has the attribute data attached to either the US or DS depending on which one I chose when I imported the CSV earlier.

The problem with this as well is the linework that does show up won't stay if I need to send the data to the client in .TAB as lots of people request, it will come through as just the initial points.

I have also tried bringing the CSV in with no geometry defined and then trying to use similar expressions to generate the linework to no avail. I have also tried using a plugin called "Shape Tools" that looked very promising as it asked me for 2 sets of co-ordinates but upon running and it seemingly working no linework is generated.

I've also checked my table structure throughout these steps to make sure my CRS is the same at all times GDA2020/PCG2020 so I'm hoping it doesn't have anything to do with this.

5
  • 1
    The geometry generator in the symbology is just that - a symbol of the chosen type, not the actual geometry. You need to use points to lines from the toolbox, and this needs an ID per line and an ascending ID of the points along this line. – Erik Sep 25 '20 at 7:36
  • Are you referring to "Points to path"? The data is a drainage network and not one continuous line which is why in the past we have required the 4 columns to designate a start and end point for each line, also creating the line this way hasn't got the attribute data attached to it. Is it possible to create these lines based off these 4 columns? – Ryan McDonald Sep 25 '20 at 7:52
  • 4
    can you provide a small sample of the line csv file – Ian Turton Sep 25 '20 at 7:59
  • 1
    If you take a look at points to path, you'll see you have two ID-fields you can use when creating the line(s) - overall sorting of the points, and then grouping the points. So this tool totally can deal with non-continuous networks. – Erik Sep 25 '20 at 8:08
  • It can deal with it I can see but the formatting of this file isn't as the command requires so in this case I don't believe I can use it. Thanks for your input though I'll look into this command and see if we can change our formatting for future. @IanTurton I'm not sure how to attach the csv new to this website sorry 1drv.ms/u/s!AnPRhaZJL0SEgVSYVOO2EqKR8N0I?e=wpVeTc Let me know if this works – Ryan McDonald Sep 25 '20 at 8:14
3

Once you have the .csv loaded into QGIS, open the Processing Toolbox and go to Vectory geometry > Geometry by expression.

The 'Input layer' should be your .csv, 'Output geometry type' should be 'Line', and write the following in 'Geometry expression': make_line(make_point("DS_X", "DS_Y"), make_point("US_X", "US_Y"))

You can just create this as a temporary layer at first and check it then to make sure it has worked correctly. This should maintain any attribute information as well.

Once created just save it off in your desired format.

0

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.