Hi, thank you for developing this package.
This question is not directly related to the primary intended use of the package, but I would appreciate any guidance. Is there a way to recover the full geometry from a path computed on a contracted graph?
contracted_path <- dodgr_paths(
graph = contracted_graph,
from = from,
to = to
)
I am generating routes iteratively to satisfy certain boundary conditions. Because this process involves many iterations, I am using a contracted graph with dodgr_paths for performance reasons, as it is significantly faster than using the full graph.
Currently, after generating a route on the contracted graph, I attempt to reconstruct the full path by computing pairwise paths on the full graph. The object route_path represents the concatenation of contracted paths across iterations:
# retrieve full transition vector for each contracted transition
transition_list <- dodgr::dodgr_paths(
graph = full_graph,
from = route_path[-length(route_path)],
to = route_path[2:length(route_path)],
pairwise = TRUE
)
# convert transitions into matrix format
transition_list <- transition_list |>
unlist(recursive = FALSE) |>
lapply(function(x) embed(x, 2)[, 2:1, drop = FALSE])
# transition data.frame
transition_df <- do.call(rbind, transition_list)
colnames(transition_df) <- c(".vx0", ".vx1")
transition_df <- data.table::as.data.table(transition_df)
# add metadata to the transitions
transition_df <- full_graph[transition_df, on = c(".vx0", ".vx1"),]
However, this approach is not valid in my case because the weighted distance (d_weighted) in the contracted graph is modified during each iteration to bias certain edge types.
Would it be possible to include a geometry column in the contracted graph that stores the corresponding full path geometry (e.g., as a sequence of coordinates or edge IDs) for each contracted edge?
If not currently supported, is there a recommended way to map contracted edges back to the original edge sequences?
Hi, thank you for developing this package.
This question is not directly related to the primary intended use of the package, but I would appreciate any guidance. Is there a way to recover the full geometry from a path computed on a contracted graph?
I am generating routes iteratively to satisfy certain boundary conditions. Because this process involves many iterations, I am using a contracted graph with
dodgr_pathsfor performance reasons, as it is significantly faster than using the full graph.Currently, after generating a route on the contracted graph, I attempt to reconstruct the full path by computing pairwise paths on the full graph. The object
route_pathrepresents the concatenation of contracted paths across iterations:However, this approach is not valid in my case because the weighted distance (
d_weighted) in the contracted graph is modified during each iteration to bias certain edge types.Would it be possible to include a geometry column in the contracted graph that stores the corresponding full path geometry (e.g., as a sequence of coordinates or edge IDs) for each contracted edge?
If not currently supported, is there a recommended way to map contracted edges back to the original edge sequences?