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

Question about route_dodgr #331

Closed
JimShady opened this issue Aug 30, 2019 · 4 comments
Closed

Question about route_dodgr #331

JimShady opened this issue Aug 30, 2019 · 4 comments

Comments

@JimShady
Copy link
Contributor

Hi @Robinlovelace and @mpadge ,

More a question, than an issue. When using route_dodgr with coordinates, does the function automatically snap the location to the nearest node on the network before starting the routing? I guess it probably does? I've been going around in circles trying to understand strange routing results, and I think that this must be the reason.

For example ....

centre                 <- c(-0.135076, 51.510115)

# Make a bounding box of 1000 metres

area                    <- st_point(centre) %>%
    st_sfc() %>%
    st_set_crs(4326) %>%
    st_transform(3857) %>%
    st_buffer(1000) %>%
    st_transform(4326) %>%
    st_bbox()

# Download the OSM network for that area

matrix_area             <- matrix(c(area$xmin, area$xmax, area$ymin, area$ymax),2)
colnames(matrix_area)   <- c('X', 'Y')

net                     <- dodgr_streetnet(pts = matrix_area,
                                           expand = 0.1) %>%
                            select(osm_id, highway) %>%
                            mutate(highway = 'pedestrian')

origin <- matrix(c(-0.135076, 51.51011), ncol=2)
dest   <- matrix(c(-0.1382889, 51.5095391), ncol=2)

my_route                <- route_dodgr(from = origin,
                                       to =   dest,
                                       net =  net)

map <- mapview(my_route)
map <- leafem::addFeatures(map, st_point(c(-0.135076, 51.51011)))
leafem::addFeatures(map, st_point(c(-0.1382889, 51.5095391)))

image

@JimShady
Copy link
Contributor Author

JimShady commented Aug 30, 2019

Although it would be hacky, I wonder if there is a way for me to split all the lines in my network into smaller lines before doing the routing. That would stop this happening I think. Maybe I can use stplanr::line_segment() ? I'll have a go and report back.

@JimShady
Copy link
Contributor Author

JimShady commented Aug 30, 2019

Thinking out loud, what the route_dodgr function should probably do is snap to the nearest line, and then to the nearest node of that line. Rather than going straight to the nearest node.

@mpadge
Copy link
Member

mpadge commented Aug 30, 2019

Yeah, you're right that snappping first to line, then to node in line, would be the way to go, but that is waaaay more computationally complicated, and so currently beyond the scope of dodgr, unfortunately.

@JimShady
Copy link
Contributor Author

Fair do, thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants