Skip to content
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

Closed
Robinlovelace opened this issue Apr 4, 2020 · 1 comment
Closed

Error with example in route() #384

Robinlovelace opened this issue Apr 4, 2020 · 1 comment

Comments

@Robinlovelace
Copy link
Member

Robinlovelace commented Apr 4, 2020

stplanr::route(pct::wight_lines_30, route_fun = osrm::osrmRoute, 
    point_input = TRUE)
#> Warning: `as_data_frame()` is deprecated as of tibble 2.0.0.
#> Please use `as_tibble()` instead.
#> The signature and semantics have changed, see `?as_tibble`.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
#> Most common output is simpleError
#> These routes failed: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
#> The first of which was:
#> <simpleError in FUN(ldf[i, 1:2], ldf[i, 3:4], ...): unused argument (point_input = TRUE)>
#> NULL

Created on 2020-04-04 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.3 (2020-02-29)
#>  os       Ubuntu 18.04.4 LTS          
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language en_GB:en                    
#>  collate  en_GB.UTF-8                 
#>  ctype    en_GB.UTF-8                 
#>  tz       Europe/London               
#>  date     2020-04-04                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version      date       lib source                             
#>  assertthat    0.2.1        2019-03-21 [2] CRAN (R 3.6.0)                     
#>  backports     1.1.5        2019-10-02 [1] CRAN (R 3.6.1)                     
#>  callr         3.4.2        2020-02-12 [1] CRAN (R 3.6.2)                     
#>  class         7.3-16       2020-03-25 [2] CRAN (R 3.6.3)                     
#>  classInt      0.4-3        2020-03-24 [1] Github (r-spatial/classInt@036a85d)
#>  cli           2.0.2        2020-02-28 [1] CRAN (R 3.6.2)                     
#>  codetools     0.2-16       2018-12-24 [4] CRAN (R 3.5.2)                     
#>  crayon        1.3.4        2017-09-16 [2] standard (@1.3.4)                  
#>  curl          4.3          2019-12-02 [2] CRAN (R 3.6.2)                     
#>  DBI           1.1.0        2019-12-15 [2] CRAN (R 3.6.2)                     
#>  desc          1.2.0        2018-05-01 [2] standard (@1.2.0)                  
#>  devtools      2.2.2        2020-02-17 [1] CRAN (R 3.6.2)                     
#>  digest        0.6.25       2020-02-23 [1] CRAN (R 3.6.2)                     
#>  dplyr         0.8.5        2020-03-07 [1] CRAN (R 3.6.3)                     
#>  e1071         1.7-3        2019-11-26 [2] CRAN (R 3.6.1)                     
#>  ellipsis      0.3.0        2019-09-20 [3] CRAN (R 3.6.1)                     
#>  evaluate      0.14         2019-05-28 [2] CRAN (R 3.6.0)                     
#>  fansi         0.4.1        2020-01-08 [1] CRAN (R 3.6.2)                     
#>  foreign       0.8-76       2020-03-03 [2] CRAN (R 3.6.2)                     
#>  fs            1.3.2        2020-03-05 [2] CRAN (R 3.6.3)                     
#>  geosphere     1.5-10       2019-05-26 [2] CRAN (R 3.6.0)                     
#>  glue          1.3.2        2020-03-12 [2] CRAN (R 3.6.3)                     
#>  highr         0.8          2019-03-20 [3] CRAN (R 3.5.3)                     
#>  htmltools     0.4.0.9003   2020-03-25 [1] Github (rstudio/htmltools@1a35072) 
#>  igraph        1.2.5        2020-03-19 [1] CRAN (R 3.6.3)                     
#>  KernSmooth    2.23-16      2019-10-15 [4] CRAN (R 3.6.1)                     
#>  knitr         1.28         2020-02-06 [1] CRAN (R 3.6.2)                     
#>  lattice       0.20-40      2020-02-19 [2] CRAN (R 3.6.2)                     
#>  lifecycle     0.2.0.9000   2020-03-16 [1] Github (r-lib/lifecycle@355dcba)   
#>  magrittr      1.5          2014-11-22 [2] CRAN (R 3.5.2)                     
#>  maptools      0.9-9        2019-12-01 [1] CRAN (R 3.6.1)                     
#>  memoise       1.1.0        2017-04-21 [3] CRAN (R 3.5.0)                     
#>  osrm          3.3.2        2019-09-23 [1] Github (rCarto/osrm@4c46b76)       
#>  pbapply       1.4-2        2019-08-31 [2] CRAN (R 3.6.1)                     
#>  pct           0.4.0        2020-03-09 [1] Github (itsleeds/pct@3dc18e1)      
#>  pillar        1.4.3        2019-12-20 [1] CRAN (R 3.6.2)                     
#>  pkgbuild      1.0.6        2019-10-09 [2] CRAN (R 3.6.1)                     
#>  pkgconfig     2.0.3        2019-09-22 [2] CRAN (R 3.6.1)                     
#>  pkgload       1.0.2        2018-10-29 [3] CRAN (R 3.5.1)                     
#>  prettyunits   1.1.1        2020-01-24 [1] CRAN (R 3.6.2)                     
#>  processx      3.4.2        2020-02-09 [2] CRAN (R 3.6.2)                     
#>  ps            1.3.2        2020-02-13 [1] CRAN (R 3.6.3)                     
#>  purrr         0.3.3        2019-10-18 [1] CRAN (R 3.6.1)                     
#>  R6            2.4.1        2019-11-12 [2] CRAN (R 3.6.1)                     
#>  raster        3.0-14       2020-04-02 [1] Github (rspatial/raster@56f961c)   
#>  Rcpp          1.0.4        2020-03-17 [1] CRAN (R 3.6.3)                     
#>  remotes       2.1.1        2020-02-15 [1] CRAN (R 3.6.2)                     
#>  rgeos         0.5-2        2019-10-03 [1] CRAN (R 3.6.1)                     
#>  rlang         0.4.5.9000   2020-03-25 [1] Github (r-lib/rlang@a90b04b)       
#>  rmarkdown     2.1.1        2020-03-25 [1] Github (rstudio/rmarkdown@947b872) 
#>  rprojroot     1.3-2        2018-01-03 [2] CRAN (R 3.5.3)                     
#>  sessioninfo   1.1.1        2018-11-05 [3] CRAN (R 3.5.1)                     
#>  sf            0.9-1        2020-03-27 [1] Github (r-spatial/sf@69c8d42)      
#>  sp            1.4-1        2020-02-28 [1] CRAN (R 3.6.2)                     
#>  stplanr       0.5.0.9000   2020-03-30 [1] Github (ropensci/stplanr@d171fd1)  
#>  stringi       1.4.6        2020-02-17 [1] CRAN (R 3.6.2)                     
#>  stringr       1.4.0        2019-02-10 [2] standard (@1.4.0)                  
#>  testthat      2.3.2        2020-03-02 [1] CRAN (R 3.6.3)                     
#>  tibble        2.99.99.9014 2020-03-27 [1] Github (tidyverse/tibble@3a050ab)  
#>  tidyselect    1.0.0        2020-01-27 [1] CRAN (R 3.6.2)                     
#>  units         0.6-6        2020-03-16 [1] CRAN (R 3.6.3)                     
#>  usethis       1.5.1.9000   2020-03-27 [1] Github (r-lib/usethis@a2c118f)     
#>  vctrs         0.2.99.9010  2020-03-27 [1] Github (r-lib/vctrs@ce16d1c)       
#>  withr         2.1.2        2018-03-15 [2] CRAN (R 3.5.3)                     
#>  xfun          0.12         2020-01-13 [1] CRAN (R 3.6.2)                     
#>  yaml          2.2.1        2020-02-01 [1] CRAN (R 3.6.2)                     
#> 
#> [1] /home/robin/R/x86_64-pc-linux-gnu-library/3.6
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/library
@Robinlovelace
Copy link
Member Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant