SouthForkResearch / pyGNAT

Geomorphic Network and Analysis Toolbox, redesigned using FOSS python libraries.
MIT License
2 stars 0 forks source link

Shortest path from upstream point to network outflow #5

Open jesselangdon opened 7 years ago

jesselangdon commented 7 years ago

Similar to Shortest path between two points (Issue #10), except the user selects an upstream reach, and only finds the path to the outflow reach (i.e. lowest point in the stream network).

MattReimer commented 7 years ago

I think networkx should be able to do this.

  1. Load the shp file into networkx.
  2. Set the directions of each segment
  3. find everything upstream using the ancestry tools
  4. From the list of everything upstream find all the outflows
  5. Loop over each outflow and calculate shortest path
  6. choose the shortest of all shortest paths.
MattReimer commented 7 years ago

See the file: https://github.com/SouthForkResearch/pyGNAT/blob/master/experiments/matt/point_to_outflow.py

I was able to specify an arbitrary starting point and traverse the network according to the line segment order until I got to an outflow point. I have no idea how correct this is but it's a start?

screen shot 2017-03-10 at 2 49 48 pm