Comments (16)
Main challenge would be converting to/from input data structures used by cppRouting
I think and I guess that would best be done in collaboration with the package author. Thoughts @vlarmet?
from sfnetworks.
I have some code with the transformations, but I think have @vlarmet collaboration would be great maybe there is better things to do it.
from sfnetworks.
@Robinlovelace I have code, that handle all the transformations using nodes, sfnetworks from/to cppRouting.
I can share it! is like half of this, the other half is connect from the points to the nodes in some way.
from sfnetworks.
Hi @latot! I'm not sure if cppRouting can be included in sfnetworks but I think that, if possible, for the time being, you could share your code here (maybe creating a new discussion) so that other users can test it and benefit from it.
from sfnetworks.
Okis! I have tested the differences, at least in speed and time we can have great benefit from it. when I have time, I'll upload it!
from sfnetworks.
Sounds great @latot happy to take a look when ready.
from sfnetworks.
@Robinlovelace @agila5 @vlarmet #254
There is discussion, has a repo with the code how to implement several functions!
from sfnetworks.
Hi all, I've had a play, in collaboration with @bda1986, and have made some progress. By coincidence, Bernhard has also written some code for sf
(but not sfnetworks
) object -> cppRouting
graph object conversion and has got some nice things working. I have not yet but wanted to report progress. Overall: I think it's well worth adding a function to help create graph
objects that can be used for cppRouting
, although I have no idea how to get geographic representations from the outputs of cppRouting
yet, with the biggest issue being the following:
route_cpp = cppRouting::get_path_pair(graph, from_graph, to_graph)
str(route_cpp)
List of 1
$ 1244_113: chr(0)
where's the route? I need to do more work to understand what is going on here...
from sfnetworks.
P.s. reproducible code in README.qmd, interested to hear if people can reproduce this and thoughts: https://github.com/streetvoronoi/streetvoronoi#routing-with-cpprouting
from sfnetworks.
Hi all, I've had a play, in collaboration with @bda1986, and have made some progress. By coincidence, Bernhard has also written some code for
sf
(but notsfnetworks
) object ->cppRouting
graph object conversion and has got some nice things working. I have not yet but wanted to report progress. Overall: I think it's well worth adding a function to help creategraph
objects that can be used forcppRouting
, although I have no idea how to get geographic representations from the outputs ofcppRouting
yet, with the biggest issue being the following:route_cpp = cppRouting::get_path_pair(graph, from_graph, to_graph) str(route_cpp) List of 1 $ 1244_113: chr(0)
where's the route? I need to do more work to understand what is going on here...
Hi, that is possible to happens, IIRC if the node 1244 is in a complete different component than 113, two different components are not connected, but this is harder to considerate with directed networks, the best would be detect it and replace with Inf.
I wanted to confirm this, sadly the docs of https://github.com/streetvoronoi/streetvoronoi#routing-with-cpprouting are not complete, the load the data and the initial variables are not described on the doc, so I was not able to follow the example.
from sfnetworks.
@Robinlovelace I was able to confirm this, I tested distance and paths, if they are in different components.
- path: will return logical(0)
- distance: will return NA
from sfnetworks.
Thanks for checking @latot. I cleaned the network by only keeping edges connected to the main component, as per this code:
net_groups = stplanr::rnet_group(net_linestrings)
largest_group = table(net_groups) |> which.max()
net_clean = net_linestrings[net_groups == largest_group, ]
How did you diagnose the issue of them being in different components and how should we fix this?
from sfnetworks.
Hi, @Robinlovelace I have updated https://github.com/latot/sample_sfnetworks_cppRouting
The shortestpath functions already has that fix, you can see it when is checked with length(), while the distance one does not have it, but I already implemented it latot/sample_sfnetworks_cppRouting@8a9a1fe.
You can se the default values I assigned is "Inf", this is because to follow the logic, the distance between two unconnected lines is Infinite.
While there is a logical issue in represent the shortest path, because there does not exists any linestring that connect both nodes, maybe the best choice would be NA? I don't like NA, because cause a lot of problem (1+NA = NA). For now I'm using an empty linestring, but can be misunderstood when you look the shortest path between the same node, (from node 1 to node 1 is an empty linestring), maybe instead of NA an empty point could do the trick, can be anything except linestring and NA, while is documented.
from sfnetworks.
Talking on postgis, thinking in how to represent this cases on the shortest path, the best answer was.
If the shortes path exists, then that linestring
The shortest path from point a to point a, is a linestring with one point, the point a
If the shortest path does not exists, use an empty linestring.
from sfnetworks.
@Robinlovelace I have updated the repo https://github.com/latot/sample_sfnetworks_cppRouting/
Now have a real example, some... simplifications? I have splittled how the functions works, and how to read the output of cppRouting, less files, I hope is easier to read.
from sfnetworks.
Awesome, many thanks! Will aim to take a look soon but may not be until next week..
from sfnetworks.
Related Issues (20)
- Test fails with the development version of igraph HOT 2
- Network cleaning: to_spatial_contracted returns mapply error HOT 4
- Converting sf_linestrings to sfnetwork causes some intersections to shift HOT 1
- Calculating Driving Distances using sfnetworks HOT 1
- Extracting GPS coordinates from SF network build from OSM Data, provides those in a wrong order HOT 8
- If the grouping variable is out of order, `to_spatial_contracted` returns incorrect node geometries HOT 1
- st_network_blend unable to blend count locations into bike network HOT 5
- Extend plot.sfnetwork to include the possibility of specifying different args for nodes and edges HOT 1
- The `trunc_mat` function we use in print.sfnetwork is deprecated HOT 2
- Enhance integration with spatstat package HOT 2
- Error when blending points into network HOT 3
- Support typed library
- Print method does not work with spatially implicit edges HOT 5
- Something wrong with calculating shortest paths HOT 1
- Edges does not follow right directions HOT 2
- Quiet option to skip validity text
- Active weight column HOT 1
- Spatstat error in CRAN checks HOT 6
- to_spatial_smooth() occurs Error in `vec_rbind()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sfnetworks.