Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update get_pfafstetter_basins.R #81

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion R/get_pfafstetter_basins.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,15 @@ g_dt_tmp <- setDT(igraph::as_data_frame(g))
g <- graph.data.frame(g_dt_tmp[,c("from", "to")], directed = T)
# Get all possible paths from the outlet
outlet = which(degree(g, v = V(g), mode = "out")==0, useNames = T)
headwater = which(degree(g, v = V(g), mode = "in")==0, useNames = T)
#headwater = which(degree(g, v = V(g), mode = "in")==0, useNames = T) # all, slow


### Get a pre-selection of those 100 main stream candidates that have the
### longest distance to the outlet (the most contributing stream is likely to
### to be one of these)
headwater <- g_dt_tmp[order(-out_dist)]$from[1:100]
headwater <- headwater[!is.na(headwater)] # remove NAs if less than 100 subc_id



# Stop if too few stream segments (currently three, need to go lower?)
Expand Down