-
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
Error with example in route() #384
Comments
With updated example: library(stplanr)
from <- c(-1.5484, 53.7941) # from <- geo_code("leeds rail station")
to <- c(-1.5524, 53.8038) # to <- geo_code("university of leeds")
r1 <- route(from, to, route_fun = cyclestreets::journey)
#> Most common output is sf
r2 <- route(from, to, route_fun = cyclestreets::journey, plan = "quietest")
#> Most common output is sf
plot(r1)
#> Warning: plotting the first 10 out of 14 attributes; use max.plot = 14 to plot
#> all plot(r2)
#> Warning: plotting the first 10 out of 14 attributes; use max.plot = 14 to plot
#> all r = route(cents_sf[1:3, ], cents_sf[2:4, ], route_fun = cyclestreets::journey) # sf points
#> Most common output is sf
summary(r$route_number)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 1.000 1.000 2.000 1.939 3.000 3.000
route(flowlines_sf[1:4, ], route_fun = cyclestreets::journey, plan = "quietest")
#> Most common output is sf
#> These routes failed: 1
#> The first of which was:
#> <simpleError in FUN(ldf[i, 1:2], ldf[i, 3:4], ...): Error: Too short: journeys must be longer than 4 metres. (Your requested journey was 0 metres).>
#> Simple feature collection with 46 features and 14 fields
#> geometry type: LINESTRING
#> dimension: XY
#> bbox: xmin: -1.55106 ymin: 53.81567 xmax: -1.5126 ymax: 53.83041
#> geographic CRS: WGS 84
#> First 10 features:
#> name distances time busynance elevations start_longitude
#> 1 Gledhow Lane 308 88 1252 112.5263 -1.51667
#> 2 Gledhow Wood Road 27 4 69 111.0000 -1.51667
#> 3 Gledhow Lane 281 52 738 106.5000 -1.51667
#> 4 Gledhow Lane 143 31 433 84.0000 -1.51667
#> 5 Gledhow Lane 550 315 3455 96.6250 -1.51667
#> 6 Gledhow Lane End 67 13 124 109.3333 -1.51667
#> 7 Town Street Walk 20 17 32 107.3333 -1.51667
#> 8 Town Street Walk 28 23 30 106.0000 -1.51667
#> 9 Town Street 56 15 217 105.8333 -1.51667
#> 10 Gledhow Lane 308 88 1252 112.5263 -1.51667
#> start_latitude finish_longitude finish_latitude route_number fx
#> 1 53.82868 -1.53556 53.82829 2 -1.516734
#> 2 53.82868 -1.53556 53.82829 2 -1.516734
#> 3 53.82868 -1.53556 53.82829 2 -1.516734
#> 4 53.82868 -1.53556 53.82829 2 -1.516734
#> 5 53.82868 -1.53556 53.82829 2 -1.516734
#> 6 53.82868 -1.53556 53.82829 2 -1.516734
#> 7 53.82868 -1.53556 53.82829 2 -1.516734
#> 8 53.82868 -1.53556 53.82829 2 -1.516734
#> 9 53.82868 -1.53556 53.82829 2 -1.516734
#> 10 53.82868 -1.55106 53.82410 3 -1.516734
#> fy tx ty geometry
#> 1 53.82887 -1.535617 53.82847 LINESTRING (-1.51667 53.828...
#> 2 53.82887 -1.535617 53.82847 LINESTRING (-1.52108 53.829...
#> 3 53.82887 -1.535617 53.82847 LINESTRING (-1.52148 53.829...
#> 4 53.82887 -1.535617 53.82847 LINESTRING (-1.52482 53.830...
#> 5 53.82887 -1.535617 53.82847 LINESTRING (-1.52606 53.829...
#> 6 53.82887 -1.535617 53.82847 LINESTRING (-1.53391 53.829...
#> 7 53.82887 -1.535617 53.82847 LINESTRING (-1.5346 53.8286...
#> 8 53.82887 -1.535617 53.82847 LINESTRING (-1.53478 53.828...
#> 9 53.82887 -1.535617 53.82847 LINESTRING (-1.53474 53.828...
#> 10 53.82887 -1.550807 53.82442 LINESTRING (-1.51667 53.828...
route(flowlines_sf[1:4, ], route_fun = cyclestreets::journey, plan = "balanced")
#> Most common output is sf
#> These routes failed: 1
#> The first of which was:
#> <simpleError in FUN(ldf[i, 1:2], ldf[i, 3:4], ...): Error: Too short: journeys must be longer than 4 metres. (Your requested journey was 0 metres).>
#> Simple feature collection with 41 features and 14 fields
#> geometry type: LINESTRING
#> dimension: XY
#> bbox: xmin: -1.55106 ymin: 53.81751 xmax: -1.5126 ymax: 53.83041
#> geographic CRS: WGS 84
#> First 10 features:
#> name distances time busynance elevations start_longitude
#> 1 Gledhow Lane 308 88 1252 112.5263 -1.51667
#> 2 Gledhow Wood Road 27 4 69 111.0000 -1.51667
#> 3 Gledhow Lane 281 52 738 106.5000 -1.51667
#> 4 Gledhow Lane 143 31 433 84.0000 -1.51667
#> 5 Gledhow Lane 550 315 3455 96.6250 -1.51667
#> 6 Gledhow Lane End 67 13 124 109.3333 -1.51667
#> 7 Town Street Walk 20 17 32 107.3333 -1.51667
#> 8 Town Street Walk 28 23 30 106.0000 -1.51667
#> 9 Town Street 56 15 217 105.8333 -1.51667
#> 10 Gledhow Lane 308 88 1252 112.5263 -1.51667
#> start_latitude finish_longitude finish_latitude route_number fx
#> 1 53.82868 -1.53556 53.82829 2 -1.516734
#> 2 53.82868 -1.53556 53.82829 2 -1.516734
#> 3 53.82868 -1.53556 53.82829 2 -1.516734
#> 4 53.82868 -1.53556 53.82829 2 -1.516734
#> 5 53.82868 -1.53556 53.82829 2 -1.516734
#> 6 53.82868 -1.53556 53.82829 2 -1.516734
#> 7 53.82868 -1.53556 53.82829 2 -1.516734
#> 8 53.82868 -1.53556 53.82829 2 -1.516734
#> 9 53.82868 -1.53556 53.82829 2 -1.516734
#> 10 53.82868 -1.55106 53.82410 3 -1.516734
#> fy tx ty geometry
#> 1 53.82887 -1.535617 53.82847 LINESTRING (-1.51667 53.828...
#> 2 53.82887 -1.535617 53.82847 LINESTRING (-1.52108 53.829...
#> 3 53.82887 -1.535617 53.82847 LINESTRING (-1.52148 53.829...
#> 4 53.82887 -1.535617 53.82847 LINESTRING (-1.52482 53.830...
#> 5 53.82887 -1.535617 53.82847 LINESTRING (-1.52606 53.829...
#> 6 53.82887 -1.535617 53.82847 LINESTRING (-1.53391 53.829...
#> 7 53.82887 -1.535617 53.82847 LINESTRING (-1.5346 53.8286...
#> 8 53.82887 -1.535617 53.82847 LINESTRING (-1.53478 53.828...
#> 9 53.82887 -1.535617 53.82847 LINESTRING (-1.53474 53.828...
#> 10 53.82887 -1.550807 53.82442 LINESTRING (-1.51667 53.828...
# with osrm backend - need to set-up osrm first - see routing vignette
if(require(osrm)) {
message("You have osrm installed")
osrm::osrmRoute(c(-1.5, 53.8), c(-1.51, 53.81))
osrm::osrmRoute(c(-1.5, 53.8), c(-1.51, 53.81), , returnclass = "sf")
# mapview::mapview(.Last.value) # check it's on the route network
route(pct::wight_lines_30[1:2, ], route_fun = osrm::osrmRoute, returnclass = "sf")
}
#> Loading required package: osrm
#> Data: (c) OpenStreetMap contributors, ODbL 1.0 - http://www.openstreetmap.org/copyright
#> Routing: OSRM - http://project-osrm.org/
#> You have osrm installed
#> Most common output is sf
#> Simple feature collection with 2 features and 9 fields
#> geometry type: LINESTRING
#> dimension: XY
#> bbox: xmin: -1.30276 ymin: 50.69411 xmax: -1.28427 ymax: 50.70328
#> geographic CRS: WGS 84
#> src dst duration distance route_number fx fy tx ty
#> 1 src dst 8.066667 1.9929 1 -1.284285 50.70326 -1.302345 50.70267
#> 2 src dst 5.731667 1.9777 2 -1.284285 50.70326 -1.301096 50.69411
#> geometry
#> 1 LINESTRING (-1.28442 50.703...
#> 2 LINESTRING (-1.28442 50.703...
if(require(cyclestreets)) { # with cyclestreets backend
route(pct::wight_lines_30, route_fun = cyclestreets::journey)
}
#> Loading required package: cyclestreets
#> Most common output is sf
#> Simple feature collection with 573 features and 14 fields
#> geometry type: LINESTRING
#> dimension: XY
#> bbox: xmin: -1.38718 ymin: 50.63295 xmax: -1.09821 ymax: 50.75952
#> geographic CRS: WGS 84
#> First 10 features:
#> name distances time busynance elevations start_longitude
#> 1 Cross Lane 118 24 203 20.200000 -1.28442
#> 2 Victoria Road 428 110 1054 14.400000 -1.28442
#> 3 Fairlee Road, A3054 35 31 439 13.000000 -1.28442
#> 4 Slip road 152 69 1236 8.142857 -1.28442
#> 5 Medina Way, A3020 204 96 4174 4.375000 -1.28442
#> 6 Slip road 62 11 222 6.833333 -1.28442
#> 7 Short un-named link 75 40 444 8.200000 -1.28442
#> 8 Hunnycross Way 219 77 585 9.000000 -1.28442
#> 9 Vicarage Walk 44 12 133 7.000000 -1.28442
#> 10 Foxes Road 37 6 60 6.000000 -1.28442
#> start_latitude finish_longitude finish_latitude route_number fx
#> 1 50.70326 -1.30224 50.70248 1 -1.284285
#> 2 50.70326 -1.30224 50.70248 1 -1.284285
#> 3 50.70326 -1.30224 50.70248 1 -1.284285
#> 4 50.70326 -1.30224 50.70248 1 -1.284285
#> 5 50.70326 -1.30224 50.70248 1 -1.284285
#> 6 50.70326 -1.30224 50.70248 1 -1.284285
#> 7 50.70326 -1.30224 50.70248 1 -1.284285
#> 8 50.70326 -1.30224 50.70248 1 -1.284285
#> 9 50.70326 -1.30224 50.70248 1 -1.284285
#> 10 50.70326 -1.30224 50.70248 1 -1.284285
#> fy tx ty geometry
#> 1 50.70326 -1.302345 50.70267 LINESTRING (-1.28442 50.703...
#> 2 50.70326 -1.302345 50.70267 LINESTRING (-1.28397 50.704...
#> 3 50.70326 -1.302345 50.70267 LINESTRING (-1.28844 50.702...
#> 4 50.70326 -1.302345 50.70267 LINESTRING (-1.28861 50.702...
#> 5 50.70326 -1.302345 50.70267 LINESTRING (-1.29056 50.701...
#> 6 50.70326 -1.302345 50.70267 LINESTRING (-1.29281 50.702...
#> 7 50.70326 -1.302345 50.70267 LINESTRING (-1.29366 50.702...
#> 8 50.70326 -1.302345 50.70267 LINESTRING (-1.29421 50.703...
#> 9 50.70326 -1.302345 50.70267 LINESTRING (-1.29706 50.702...
#> 10 50.70326 -1.302345 50.70267 LINESTRING (-1.29764 50.702... Created on 2020-04-04 by the reprex package (v0.3.0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created on 2020-04-04 by the reprex package (v0.3.0)
Session info
The text was updated successfully, but these errors were encountered: