I have got a vector layer with one feature (MultiLineString) representing a river network (s. below) without bifurcations. In addition there is a point shapefile containing the outlets of different subcatchments and one polygon for each of them.

Example: in the following image, the length should be from A (outlet, point in shapefile) to B (should be found automatically). As the point at A is not exactly on the line, an ideal solution would replace the outlet onto the line.

Drainage network and catchment outlets

Is there a simple way to calculate the longest flow path (one single branch) in QGIS? The final goal is to have one length for each subcatchment.

  • How is flow direction represented in a single linear feature?
    – Spacedman
    Apr 23, 2018 at 22:13
  • There is no flow information. Basically there is just a branched line with the catchment outlet at one point.
    – NicoH
    Apr 24, 2018 at 6:55
  • How is the catchment outlet point identified in the data? Is it always the very first vertex? And the network is a tree-shaped network with no bifurcations (your rivers never split, only join)? Could you point us to some sample data sets?
    – Spacedman
    Apr 24, 2018 at 7:09
  • still missing information?
    – NicoH
    Apr 24, 2018 at 14:13
  • Yes, what would be the "longest flow path" for your example? Where would it start, and where would it end? The longest path on that network would be going upstream and downstream, so I don't see yet how to figure out where to go.
    – Spacedman
    Apr 24, 2018 at 19:31

1 Answer 1


There is a tool in Whitebox Geospatial Analysis Tools called Vector Stream Network Analysis within the Stream Network Analysis toolbox. It will take a shapefile stream network, that does not contain topological information about flow direction among stream links, and a coarse resolution DEM as inputs. It will output a number of stream metrics for each stream link in the attribute table including:

enter image description here

Extracting each link containing 'true' for the MAINSTREAM attribute, will isolate your longest path in each network. Here's an example of the Grand River network in Ontario:

enter image description here

The tool isn't well documented because I am still in the process of publishing the paper related to the tool.

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.