-
Notifications
You must be signed in to change notification settings - Fork 66
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
sum_network_routes() + sfNework returns error when 'start' and 'end' are the same node #444
Comments
Hi @jmlondon and thank you for your message! IMO it's not extremely difficult to fix this problem, but I'm not sure about the best approach. My idea would be adding an I'm not 100% sure if the output should be a POINT object (i.e. the common node) or a (degenerate) LINESTRING object (as you suggest). I would opt for the POINT object, but this is clearly open to discussion. Btw: I briefly checked your R package, and it looks really good! |
I'm not sure what the best or most appropriate result would be either. I suggested the degenerate LINESTRING option because that was consistent with behavior when passing a SpatialLinesNetwork. I think there could also be some downstream benefits (or, at least, reduced headaches) in having If you decide to go with POINT, I would suggest updating the behavior for SpatialLinesNetwork for consistency. There is, also, an interesting philosophical (or semantic) question whether pathfound should be TRUE or FALSE in this situation. As a naive user, I was expecting it to still be TRUE. But, then again, is a path of length 0 still a path? hmmm Regarding, {pathroutr}, thanks! I'm excited for the potential but it's still early days in development. I might be back here with questions or other issues as I try to scale it up to large and more realistic and more complex environments. |
Update on this @jmlondon yes I think this is a good idea. Many thanks for flagging the issue, LINESTRING consistently will definitely be more consistent. |
* First ideas for #444 * try fix the scenario with degenerate and regular routes * fix docs for sum_network_routes
Great reproducible report @jmlondon and great fix @agila5. Code shown below shows: it works 🎉 remotes::install_github("agila5/stplanr", "network_identical_nodes")
library(stplanr)
library(sf)
sln_sf <- SpatialLinesNetwork(route_network_sf)
line1 <- sum_network_routes(sln_sf, start = c(1, 2), end = c(9, 13))
line2 <- sum_network_routes(sln_sf, start = 1, end = 1)
plot(sln_sf@sl$geometry)
plot(line1$geometry, add = TRUE, lwd = 5)
plot(line2$geometry, add = TRUE, lwd = 20) |
Hello
There seems to be a rather unique situation where
sum_network_routes()
returns an Error when sln is ansfNetwork
object and the start and end node are the same. This is not the case when sln is aSpatialLinesNetwork
object.It seems the preferred response would be an sf LINESTRING with the same start/end coords and length NA.
In my situation, this came up as I was calculating shortest path based on results from
find_network_nodes()
and the closest node to the given coordinates turned out to be the same.The following reprex should demonstrate the issue.
Created on 2020-11-24 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: