Comments (1)
Hi @swaheera,
After reviewing your code I see a couple of issues.
- The way you define your start and end points is not entirely correct. When you set the CRS, you are basically telling sf to assign a EPSG:3347 to coordinates that actually are in EPSG:4326 as given above. To correct this you should do something like:
q1 <- st_transform(st_sfc(q1, crs = st_crs(4326)) , st_crs(a))
q2 <- st_transform(st_sfc(q2, crs = st_crs(4326)) , st_crs(a))
- When you create the network
as_sfnetwork()
defaults to directed networks. This usually is a tricky setting knowing that many road networks are not correctly digitized. The algorithm doesnot find a path between your points because of the direction of the edges. To avoid this you can use:
net <- as_sfnetwork(a, directed = FALSE)
- In your original code you were getting a result already stored on the paths object. This is where all the nodes and edges of you resulting path are located as list objects. If you are only looking for the distance however, I would recommend you to call
st_network_cost(net, q1, q2)
. This will directly give you the shortest network distance in meters between your two points.
If hope you don't mind that I convert this issue to a discussion. If you have any question we can discuss there 😄
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
- 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
- Support cppRouting HOT 16
- 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 HOT 2
- 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.