1

I need to split lines (rivers) to upper and lower parts (upstream and downstream) by points (fish barrier). All the original lines start from upstream and end downstream (picture).

SAGA's "Split Lines at Points" will do the splitting just fine. After that I would need to produce an attribute for each line with one value for all upstream lines and another for all downstream lines, but have not succeeded in doing that.

I'm thinking maybe the direction of the line would be useful for defining upstream and downstream, as the original lines start always from upstream. There's also the fact that lines start from higher altitude than they end, so using a DEM would maybe an option too, but that sounds difficult.

I'm using QGIS 3.34.1.

Quick and dirty picture

omomom
  • 11
  • 2
  • Have you tried SAGA's "Split Lines at Points" processing algorithm ? Does this answer your question? Splitting line layer using another point layer in QGIS – Kalak Dec 20 '23 at 10:24
  • Partly. On top of that I need to seperate the lines to two different groups: downstream and upstream. – omomom Dec 20 '23 at 10:56
  • Probably you should explain what you mean by "separating" downstream and upstream... If you split the lines at a point, they are "separated"...? So what does "separating" mean and based on what criteria you distinguish between both? – Babel Dec 20 '23 at 15:29
  • Sorry for the unclear question. I mean I need to have a attribute for the lines with one value for all upstream lines and another for all downstream lines. I'm thinking maybe the direction of the line would be useful for defining upstream and downstream, as the original lines start always from upstream. – omomom Dec 21 '23 at 07:30

1 Answers1

1

Your problem is a network problem and can be solved using Shortest Path (Layer to Point) algorithm. The question is: from which ones of the start points of each line is the split point (barrier) reachable over the network (river lines), using only forward (=line) direction? So to say: from which start points, the water will sooner or later flow through the barrier? Like this, you have identified the upstream lines. Inversely, all other lines are downstream lines.

Start points (blue), split point (red) and lines with arrows indicating line direction: The line's color here is already categorized in upstream (red) and downsream (blue), based on the attribute value of the filed stream (see step 3 below): enter image description here

Proceed as follows. If you want to run it at once for several split points (different river systems) at once, run it in Batch mode.

  1. Extract the start points of your lines using Geometry by Expression with the expression start_point ($geometry).

  2. Run Shortest Path (Layer to Point) and use the lines (rivers) as network layer, the layer from step 1 as start points and the split points (barrier) as end point. Expand Advanced Parameters and set Default direction to Forward direction.

  3. The output are the upstream lines. So now on your initial line layer, create a new attribute with field calculator to check which of these lines intersect with these upstream lines from step 2 to categorize your initial lines in upstream/downsream. Use this expression:

     case 
         when overlay_intersects ('shortest_path') -- change layer name if necessary
         then 'upstream'
         else 'downstream'
     end
    
Babel
  • 71,072
  • 14
  • 78
  • 208