Replies: 2 comments
-
Hi Emantzo, this is a very good question. I think the basic answer is 'yes but it could be easier'. I think the process of answering the question with reference to a reproducible example could improve the package. Do you have a reprex to illustrate how you're hoping it will work? Basically I think a type of |
Beta Was this translation helpful? Give feedback.
-
I agree @emantzo that it is indeed a very good question, and also agree with @Robinlovelace that "it could be easier". library (dodgr)
library (stplanr)
net <- readRDS ("<dodgr_streetnet>/<result>t.Rds")
xy <- sf::st_coordinates (net$geometry)
xy_i <- xy [sample (nrow (xy), size = 2), 1:2]
r <- route_dodgr (xy_i [1, ], xy_i [2, ], net = net)
head (as.matrix (r$geometry [[1]]))
#> x y
#> 201920 7.794609 51.92786
#> 201918 7.790919 51.92823
#> 201916 7.788843 51.92839
#> 201914 7.787338 51.92845
#> 201912 7.784688 51.92844
#> 201910 7.782649 51.92841 That matrix has row names, but they are meaningless there, because they are extracted from an net_d <- weight_streetnet (net)
p <- dodgr_paths (graph = net_d,
from = xy_i [1, ],
to = xy_i [2, ])
p <- p [[1]] [[1]] # first and only from/to pair
p_to_from <- apply (cbind (p [-length (p)], p [-1]), 1, function (i)
paste0 (i [1], "==", i [2]))
g_to_from <- apply (net_d [, c ("from_id", "to_id")], 1, function (i)
paste0 (i [1], "==", i [2]))
index <- match (p_to_from, g_to_from)
ways <- net_d$way_id [index]
head (ways)
#> [1] "146458930" "146458930" "146458930" "146458930" "146458930" "146458930" Created on 2021-07-15 by the reprex package (v2.0.0.9000) And those are the way ID values from OSM which the route traverses. @Robinlovelace the way i see it, the only way to achieve this ability reliably is to use the |
Beta Was this translation helpful? Give feedback.
-
Hi, congrats on this nice work and package!
Is there a straightforward way to link the routes (produced with route()) with the actual streets (eg from osm data), to find which streets are included in each route ?
Maybe my question is naive, I am very new to this !
Thank you for your time!
Beta Was this translation helpful? Give feedback.
All reactions