Question
I have a multipart line representing a river, downloaded from OSM. It includes minor branches as well (see screenshot). For cartographic purpose, I want to convert the line to a single part geometry, keeping just one single feature representing the river from source to mouth. I don't care which segments are kept as long as the main course of the river is represented more or less (I will generalize the line anyway).
How can I get rid of multiple branches (side lines) to get a single feature for the whole line?
Screenshot: downloaded river: multipart line with two side branches that I want to delete, keeping just one single line representing the river's general course. However, this section of the river consists of three parts (in different colors), so I can't simply delete one of the parts, just some segments. A valid solution here would be, if the river flows form left to right, deleting the end of the red line and the beginning of the blue line - or, alternatively, start and end of orange line, keeping just the middle section:
Context
I downloaded the river line-layer from OpenStreetMap using QuickOSM plugin with waterway=river
and name=[Name of the river]
. For cartographic purpose, I now want to use a style to show the river with varying width from source to mouth (I additionally use Geometry Generator to generalize and smooth the river's course, but that does not matter here).
This is easy using Symbol layer type Interpolated Line
with Start value 0
and End value length($geometry)
, then load the actual min/max values (0 to the total length of the river) and setting a width at the source and one at the mouth to get a line with steadily increasing width from source to mouth.
Generalized and smoothd line with interpolated line style with varying width - this is how the result should look like:
What I tried
Interpolated line style creates the result I'm looking for using a single part line without branches. A workaround is using network tool Shortest path (point to point)
, selecting manually source and mouth of the river to get one single line (the shortest connection from source to mouth). This works well, but is cumbersome to do for each river separately and I want to automatize it with a model.
Due to the data downloaded from OSM, I can't use start-/end point of the line as the line layer contains several features so I get additional start points somewhere in the middle of the course of the river.