-
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
Add new node to SpatialLinesNetwork #237
Comments
The issue here is that the routing done on a SpatialLinesNetwork (and the network created from it) is generated from the end points of each line (the nodes), rather than the intermediate coordinates along the line. If you want to add a new node to your network, you need to split your existing SpatialLinesDataFrame at the node then recreate the SpatialLinesNetwork. I have done something similar before (see #92). I'll find where I saved the code for that so you can see how it works. |
Could you provide an example of this? Could add it to the route network vignette - I think there is scope for this. Heads-up @rafapereirabr finally picking up on this. Any further updates your end? |
For posterity, see here: https://docs.ropensci.org/stplanr/articles/stplanr-route-nets.html#adding-new-nodes I've documented quite a low level solution. In the future there's definitely scope for creating a function to do this work. |
Heads-up @agila5, the link above should help with the roundabout issue. To be discussed! |
Hi Robin! thanks. It looks great. I think it would be good to have a function to make this solution more easily applicable to other cases. I've worked on your code to propose the following function. (see reproducible test below) function
data for reproducible example
using the functionThe function returns the original network with an additional node
|
How can one use a
SpatialPointsDataFrame
do add a new node to aSpatialLinesNetwork
?context of my problem: I have a shapefile of a bus route and another shapefile of bus stops. I want to calculate the distance between stops along the bus route. Ideally, each stop would be a node and I would use stplanr::sum_network_routes() to calculate the distance between them. The problem is that when I convert the bus route into a SpatialLinesNetwork the network only has a few nodes far from each other.
reproducible dataset:
ps. I've asked this question on SO and Robin asked to share it here as well
The text was updated successfully, but these errors were encountered: