VeinsOfTheEarth / RivGraph

Extracting and quantifying graphical representations of river and delta channel networks from binary masks
https://veinsoftheearth.github.io/RivGraph/
Other
82 stars 26 forks source link

Over- or under-pruning of masks that don't have an ocean #25

Closed jonschwenk closed 4 years ago

jonschwenk commented 4 years ago

If a channel network mask is provided for which the outlet links are not connected via an ocean or other waterbody, the pruning performed by prune_network() either removes too much of the network or doesn't prune anything.

Example: Binary mask image

Network: image

Pruned network (and shoreline): image No actual pruning was performed in this case.

This likely arises from the initial development of pruning algorithms which assumed that outlet links would be connected by a waterbody--typically an ocean or lake. This assumption needs to be corrected.

Lvulis commented 4 years ago

Jon, per email discussions:

The prune network call has a basic assumption that all channels are connected, so headless channels aren't considered. This is from the description of the channel network taken in Tejedor et al., 2015, right? Will be challenging to overturn that assumption, or require some "options" to allow or not allow headless channels or a non-fully connected network to exist.

jonschwenk commented 4 years ago

If I'm understanding you correctly, that is a separate issue somewhat. The network shown above is a tidal network, with many "headless" channels. You can run RG in "reverse" if you want to extract the network as one connected component. I.e. treat the outlet as the inlet and draw the shoreline around the inlets so they're considered outlets. That is what led to this bug--in that case, there is no waterbody connecting all the "outlets" and RG fails.

The current advice for networks with many disconnected channels is to mask each one individually. E.g. on the Niger, there are two disconnected tidal networks above and below the riverine-fed network; you have to make separate masks for each of these and process independently. I would consider the headless case to be an enhancement, not a bug, as the intention was never for RG to deal with those cases. However, I have run into cases where it would be useful to have some functionality to handle them.

Pruning itself could use some finer-tuning parameters. Currently, all spur links (i.e. those connected to the network at only one end) are iteratively removed until none remain, with the exception of inlet/outlet links. This might not be desirable in all cases; e.g. when one wants the total channel length of the network, including headless channels. This gets tricky because of how skeletonization returns spurs; it becomes difficult to tell a spur from a true channel automatically.

Lvulis commented 4 years ago

Jon,

Sorry for leaving you on read here as we had pushed past this part of the analysis by getting the full water masks. I meant to say that in my opinion the tidal networks (headless channels) are not part of the DCN-structure that was described in Alex's papers so losing them is OK to perform the graph analysis.

jonschwenk commented 4 years ago

No worries, I fixed this bug but haven't updated the repo yet.

You're right that these channels are not important for the graph-based metrics, but the reason they've become important for some work I'm doing is that we want to normalize some graph-based metrics by, e.g. total channel network length across the delta, which includes the disconnected tidal channels for my particular case.

The other alternative I've found (in addition to tricking RG to think the headless channels are the outlets) is to simply connect all of them in the mask, then RG as normal, then remove the connecting links. Kind of a pain to do this way though, esp. with lots of "headless" channels.

Lvulis commented 4 years ago

Sounds cumbersome unless you can do some automatic detection to link the heads temporarily and store the 'fake water' you use to make the links...

jonschwenk commented 4 years ago

Doable if you paint the false channels as a different number (instead of 1 or 0), then binarize.

On Thu, Sep 3, 2020 at 4:05 PM Lawrence V. notifications@github.com wrote:

Sounds cumbersome unless you can do some automatic detection to link the heads temporarily and store the 'fake water' you use to make the links...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jonschwenk/RivGraph/issues/25#issuecomment-686787878, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRPO5IGQDAQRYAK7S7JPN3SEAHLTANCNFSM4QFCORQQ .

jonschwenk commented 4 years ago

This bug has been fixed.