Efficient creation of paths to feed into Overline #491
blackburnstat
started this conversation in
General
Replies: 1 comment 1 reply
-
Hi @blackburnstat thanks for the question and sorry I don't have a quick answer: I don't think your code is fully reproducible so difficult to test solutions. Another suggestion: have you tried |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Apologies if this is a basic question/not in the right place.
I have used StPlanR to map origin-destination tonnage information onto the Inland Waterway network. My code is here.
https://github.com/blackburnstat/Mapping_IWW_tonnage/blob/main/IWW%20OD_realmap_downloadShapefromweb.R
It works (I think?) but takes a long time, 30 minutes plus. The wait time is caused by having several thousand paths (named path_graphNN) that need to be combined into a single object in order to feed into overline, as below.
for (i in 1:length_NUTS){
my_big_epath_list[i]<-
shortest_paths(graph = graph,from = node_index_master[i,1], to = node_index_master[i,2],
output = 'epath',weights = graph %>%
activate(edges) %>%
pull(SECTION_LE)
)$epath
}
for (i in 1:length_NUTS){
assign(paste0("path_graph",i), graph %>%
subgraph.edges(eids = my_big_epath_list[i] %>%
unlist()) %>%
as_tbl_graph() %>%
activate(edges) %>%
mutate(tonnage=IntNuts$tonnage[i]) %>%
as_tibble() %>%
# select(from,to,NOM,length,SECTION_LE) %>% #27JULY TEST TO MAKE THE OBJECTS SMALLER
st_as_sf())
}list_paths<-mget(ls(pattern='^path\_graph\d'))
combined_graphs<-do.call(rbind,list_paths)
combined_graphs2<-st_set_crs(combined_graphs,3857)
overlined_segments<-overline(combined_graphs,attrib="tonnage")
Am I going about this problem the wrong way?
Thanks for any help.
Beta Was this translation helpful? Give feedback.
All reactions