-
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 functions to split routes and add nodes route networks #342
Comments
It's worth splitting the line splitting and node adding components into different functions. |
Now implemented in the remotes::install_github("ropensci/stplanr", "rnet-add-node")
#> Skipping install of 'stplanr' from a github remote, the SHA1 (d5e0b0a3) has not changed since last install.
#> Use `force = TRUE` to force installation
library(stplanr)
#> Registered S3 method overwritten by 'R.oo':
#> method from
#> throw.default R.methodsS3
sample_routes = routes_fast_sf[2:6, NULL]
sample_routes$value = rep(1:3, length.out = 5)
rnet = overline2(sample_routes, attrib = "value")
#> 2019-09-24 09:37:14 constructing segments
#> 2019-09-24 09:37:14 building geometry
#> 2019-09-24 09:37:14 simplifying geometry
#> 2019-09-24 09:37:14 aggregating flows
#> 2019-09-24 09:37:14 rejoining segments into linestrings
sln = SpatialLinesNetwork(rnet)
#> Linking to GEOS 3.7.1, GDAL 2.4.2, PROJ 5.2.0
p = sf::st_sfc(sf::st_point(c(-1.540, 53.826)), crs = sf::st_crs(rnet))
sln_nodes = sln2points(sln)
sln_new = sln_add_node(sln, p)
#> although coordinates are longitude/latitude, st_nearest_feature assumes that they are planar
route = route_local(sln_new, p, sln_nodes[9, ])
plot(sln)
plot(sln_nodes, pch = as.character(1:nrow(sln_nodes)), add = TRUE)
plot(route$geometry, lwd = 9, add = TRUE) Created on 2019-09-24 by the reprex package (v0.3.0) Work for you @rafapereirabr? Any feedback welcome. |
Note that |
Great stuff. This functionality should come relatively soon into |
This works like a charm. Thanks Robin ! |
And please feel free to add an answer to that SO question:
|
Emerging from #237 (comment), suggestion from @rafapereirabr
The text was updated successfully, but these errors were encountered: