ropensci / stplanr

Sustainable transport planning with R
https://docs.ropensci.org/stplanr
Other
421 stars 66 forks source link

Implement route_dodgr #247

Closed Robinlovelace closed 5 years ago

Robinlovelace commented 6 years ago

As discussed with @mpadge. Related to #246. Links to the need for a route_local() function that wraps SpatialLinesNetwork().

Robinlovelace commented 5 years ago

No time like the present!

See https://github.com/ITSLeeds/pct/issues/27

Heads-up @mpadge and @layik.

mpadge commented 5 years ago

A "proper" implementation needs a few efficiency tweaks from that code, mostly through using match_pts_to_graph(). Point me to where in the code this should live, and I'll happily implement it.

Robinlovelace commented 5 years ago

Many thanks Mark. The code would live here:

https://github.com/ropensci/stplanr/blob/master/R/route.R#L85

mpadge commented 5 years ago

Cool! I've got a day off tomorrow, and a weekend of fun times, but will get on to it first thing Monday.

Robinlovelace commented 5 years ago

Great. Here's where my code gets to (downloading the rnet if it's not already there, which will be really useful IMO). I await your PR, many thanks!

devtools::install_github("ropensci/stplanr")
#> Skipping install of 'stplanr' from a github remote, the SHA1 (4b1c758c) has not changed since last install.
#>   Use `force = TRUE` to force installation
    library(stplanr)
    from <- sf::st_coordinates(cents_sf[1, ])
    to <- sf::st_coordinates(cents_sf[2, ])
    r <- route_dodgr(from, to)
#> Warning: plotting the first 9 out of 30 attributes; use max.plot = 30 to
#> plot all

Created on 2019-03-14 by the reprex package (v0.2.1)

Robinlovelace commented 5 years ago

Heads-up @mpadge I've had a first bash at this. Look OK to you? I've used nabor rather than dodgr to match the points, which is probably not optimal. Very happy to see it working in any case. Next step, I guess, is adding route (optional) route statistics, such as distance and perhaps other summary stats.

mpadge commented 5 years ago

yo @Robinlovelace, I've done this, but just need to iron out a couple of issues before I push. Didn't modify your code that much, but just implemented the ability to input multiple from and to points, and to return a full multi-row sf data.frame with details of start and end points, and geometry containing the routes. I'll send PR tomorrow morning

Robinlovelace commented 5 years ago

Sounds great to me. Many thanks, looking forward to the PR - being able to pass route_dodgr() many OD pairs will be awesome.

gert08 commented 5 years ago

Hi, I'm trying to use the function and I can not get past this error:

_Error in is_numeric_matrix(x) : is.numeric(x) && is.matrix(x) is not TRUE_

I suppose that as.matrix () is not converting the list properly to pass it to st_linestring (). I am not very expert in the subject and I would like to know if it is only with my data or it is a problem of the function.

Greetings,

mpadge commented 5 years ago

That's likely because your installed package versions are a bit out of date. Please try remotes::install_github("atfutures/dodgr") and let us know if that fixes. Maybe also same for stplanr° If that doesn't work, then please try to include some reproducible code

gert08 commented 5 years ago

Thank you very much, I did what you said and cleaned the workspace but I still get the same error:

library(dplyr)

#> Warning: package 'dplyr' was built under R version 3.6.1
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
  library(sf)
#> Warning: package 'sf' was built under R version 3.6.1
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
  library(osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright
  library(dodgr)
  library(stplanr)
#> Registered S3 method overwritten by 'R.oo':
#>   method        from       
#>   throw.default R.methodsS3
  bb99 <- c(-8.5728, 43.2368,-8.1657,43.4034)

#Descargar las calles del area a un osmdata_sf
area99<- opq(bbox = bb99) %>%
  add_osm_feature(key = 'highway')%>% osmdata_sf() 
#Objeto sf
area99_sf <- area99$osm_lines %>%
  st_transform(crs ="+proj=longlat +ellps=WGS84")

from <- structure(list(X = c(-8.42006027698517, -8.20952297835075, -8.42643857002258, 
                             -8.41481924057007, -8.41923952102661, -8.41465830802918, -8.41951957008356, 
                             -8.38328182697296, -8.35565439254155, -8.43316555023194, -8.4194424547759, 
                             -8.42190563678742, -8.40007245540619, -8.44299852848053, -8.41782331466675
), Y = c(43.3650984295013, 43.2767695265241, 43.3608434951152, 
         43.3577388817328, 43.3713262417024, 43.3647396381231, 43.3586539122512, 
         43.3067747933252, 43.3028463919537, 43.3757325102483, 43.3605667983998, 
         43.3584838474195, 43.3795731114911, 43.3236166758399, 43.3605899836471
)), row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", 
                  "10", "11", "12", "13", "14", "15"), class = "data.frame")

to <- structure(list(X = -8.413942, Y = 43.36652), class = "data.frame", row.names = "1")

r <- route_dodgr(from, to, net = area99_sf)
#> Error in is_numeric_matrix(x): is.numeric(x) && is.matrix(x) is not TRUE
Created on 2019-07-13 by the reprex package (v0.3.0)
mpadge commented 5 years ago

Yep, I can reproduce that - thanks @gert08 for the code. I'll dig deeper, and report back

mpadge commented 5 years ago

@Robinlovelace It's a bug in the route_dodgr code - one of those paths comes back empty, and these lines then fail. Do you want me to PR a fix? There's also another bit of a bug, in that the from/to pairs are submitted as matched columns of the od_coordinate_matrix object, and so in the case given of a single to point simply repeats those coordinates to create a to column the same length as from. This is, however, not howdodgris set up, and it ends up doingnrow` times as many calculations as necessary. I should fix that too ...

Robinlovelace commented 5 years ago

Hi @gert08 thanks for the reproducible example, and massive thanks to @mpadge for the quick fix.

Full reprex with current version of stplanr gives:

library(sf)
#> Linking to GEOS 3.5.1, GDAL 2.1.2, PROJ 4.9.3
    library(stplanr)
#> Registered S3 method overwritten by 'R.oo':
#>   method        from       
#>   throw.default R.methodsS3
    library(osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright
    packageVersion("stplanr")
#> [1] '0.2.10.9000'

    bb99 <- c(-8.5728, 43.2368,-8.1657,43.4034)

    area99<- opq(bbox = bb99) %>%
        add_osm_feature(key = 'highway')%>% osmdata_sf() 
    #Objeto sf
    area99_sf <- area99$osm_lines %>%
        st_transform(crs ="+proj=longlat +ellps=WGS84")

    from <- structure(list(X = c(-8.42006027698517, -8.20952297835075, -8.42643857002258, 
                                 -8.41481924057007, -8.41923952102661, -8.41465830802918, -8.41951957008356, 
                                 -8.38328182697296, -8.35565439254155, -8.43316555023194, -8.4194424547759, 
                                 -8.42190563678742, -8.40007245540619, -8.44299852848053, -8.41782331466675
    ), Y = c(43.3650984295013, 43.2767695265241, 43.3608434951152, 
             43.3577388817328, 43.3713262417024, 43.3647396381231, 43.3586539122512, 
             43.3067747933252, 43.3028463919537, 43.3757325102483, 43.3605667983998, 
             43.3584838474195, 43.3795731114911, 43.3236166758399, 43.3605899836471
    )), row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", 
                      "10", "11", "12", "13", "14", "15"), class = "data.frame")

    to <- structure(list(X = -8.413942, Y = 43.36652), class = "data.frame", row.names = "1")

    r <- route_dodgr(from, to, net = area99_sf)
#> Error in is_numeric_matrix(x): is.numeric(x) && is.matrix(x) is not TRUE

    plot(r)
#> Error in plot(r): object 'r' not found

Created on 2019-07-15 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> ─ Session info ────────────────────────────────────────────────────────── #> setting value #> version R version 3.6.0 (2019-04-26) #> os Debian GNU/Linux 9 (stretch) #> system x86_64, linux-gnu #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Etc/UTC #> date 2019-07-15 #> #> ─ Packages ────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0) #> backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.0) #> callr 3.3.0 2019-07-04 [1] CRAN (R 3.6.0) #> class 7.3-15 2019-01-01 [2] CRAN (R 3.6.0) #> classInt 0.3-3 2019-04-26 [1] CRAN (R 3.6.0) #> cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.0) #> codetools 0.2-16 2018-12-24 [2] CRAN (R 3.6.0) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0) #> curl 3.3 2019-01-10 [1] CRAN (R 3.6.0) #> DBI 1.0.0 2018-05-02 [1] CRAN (R 3.6.0) #> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.0) #> devtools 2.1.0 2019-07-06 [1] CRAN (R 3.6.0) #> digest 0.6.20 2019-07-04 [1] CRAN (R 3.6.0) #> dodgr 0.2.0 2019-06-05 [1] CRAN (R 3.6.0) #> dplyr 0.8.3 2019-07-04 [1] CRAN (R 3.6.0) #> e1071 1.7-2 2019-06-05 [1] CRAN (R 3.6.0) #> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0) #> foreign 0.8-71 2018-07-20 [2] CRAN (R 3.6.0) #> fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.0) #> geosphere 1.5-10 2019-05-26 [1] CRAN (R 3.6.0) #> glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0) #> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0) #> htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.6.0) #> httr 1.4.0 2018-12-11 [1] CRAN (R 3.6.0) #> igraph 1.2.4.1 2019-04-22 [1] CRAN (R 3.6.0) #> jsonlite 1.6 2018-12-07 [1] CRAN (R 3.6.0) #> KernSmooth 2.23-15 2015-06-29 [2] CRAN (R 3.6.0) #> knitr 1.23 2019-05-18 [1] CRAN (R 3.6.0) #> lattice 0.20-38 2018-11-04 [2] CRAN (R 3.6.0) #> lubridate 1.7.4 2018-04-11 [1] CRAN (R 3.6.0) #> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0) #> maptools 0.9-5 2019-02-18 [1] CRAN (R 3.6.0) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.0) #> openxlsx 4.1.0.1 2019-05-28 [1] CRAN (R 3.6.0) #> osmdata * 0.1.1 2019-05-22 [1] CRAN (R 3.6.0) #> pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.0) #> pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.6.0) #> pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.6.0) #> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.0) #> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.0) #> processx 3.4.0 2019-07-03 [1] CRAN (R 3.6.0) #> ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.0) #> purrr 0.3.2 2019-03-15 [1] CRAN (R 3.6.0) #> R.methodsS3 1.7.1 2016-02-16 [1] CRAN (R 3.6.0) #> R.oo 1.22.0 2018-04-22 [1] CRAN (R 3.6.0) #> R.utils 2.9.0 2019-06-13 [1] CRAN (R 3.6.0) #> R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.0) #> raster 2.9-5 2019-05-14 [1] CRAN (R 3.6.0) #> Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.6.0) #> RcppParallel 4.4.3 2019-05-22 [1] CRAN (R 3.6.0) #> remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.0) #> rgeos 0.4-3 2019-04-24 [1] CRAN (R 3.6.0) #> rlang 0.4.0 2019-06-25 [1] CRAN (R 3.6.0) #> rmarkdown 1.13 2019-05-22 [1] CRAN (R 3.6.0) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0) #> rvest 0.3.4 2019-05-15 [1] CRAN (R 3.6.0) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0) #> sf * 0.7-6 2019-07-05 [1] CRAN (R 3.6.0) #> sp 1.3-1 2018-06-05 [1] CRAN (R 3.6.0) #> stplanr * 0.2.10.9000 2019-07-11 [1] local #> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0) #> testthat 2.1.1 2019-04-23 [1] CRAN (R 3.6.0) #> tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.0) #> tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.6.0) #> units 0.6-3 2019-05-03 [1] CRAN (R 3.6.0) #> usethis 1.5.1 2019-07-04 [1] CRAN (R 3.6.0) #> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0) #> xfun 0.8 2019-06-25 [1] CRAN (R 3.6.0) #> xml2 1.2.0 2018-01-24 [1] CRAN (R 3.6.0) #> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0) #> zip 2.0.3 2019-07-03 [1] CRAN (R 3.6.0) #> #> [1] /usr/local/lib/R/site-library #> [2] /usr/local/lib/R/library ```
gert08 commented 5 years ago

Thank you and @mpadge for your work, know it's working, but in the original file I have 288 points of which I only found paths for 222 points towards the destination. Do you think I could be missing something?

Robinlovelace commented 5 years ago

Update showing working code below. @gert08 could you provide clarity on what you expect the output to be based on this reprex?

remotes::install_github("atfutures/dodgr")
#> Skipping install of 'dodgr' from a github remote, the SHA1 (d8bf3fb1) has not changed since last install.
#>   Use `force = TRUE` to force installation
    remotes::install_github("mpadge/stplanr")
#> Skipping install of 'stplanr' from a github remote, the SHA1 (a342489f) has not changed since last install.
#>   Use `force = TRUE` to force installation
    library(sf)
#> Linking to GEOS 3.5.1, GDAL 2.1.2, PROJ 4.9.3
    library(stplanr)
#> Registered S3 method overwritten by 'R.oo':
#>   method        from       
#>   throw.default R.methodsS3
    library(osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright
    packageVersion("stplanr")
#> [1] '0.2.10.9000'

    bb99 <- c(-8.5728, 43.2368,-8.1657,43.4034)

    area99<- opq(bbox = bb99) %>%
        add_osm_feature(key = 'highway')%>% osmdata_sf() 
    #Objeto sf
    area99_sf <- area99$osm_lines %>%
        st_transform(crs ="+proj=longlat +ellps=WGS84")

    from <- structure(list(X = c(-8.42006027698517, -8.20952297835075, -8.42643857002258, 
                                 -8.41481924057007, -8.41923952102661, -8.41465830802918, -8.41951957008356, 
                                 -8.38328182697296, -8.35565439254155, -8.43316555023194, -8.4194424547759, 
                                 -8.42190563678742, -8.40007245540619, -8.44299852848053, -8.41782331466675
    ), Y = c(43.3650984295013, 43.2767695265241, 43.3608434951152, 
             43.3577388817328, 43.3713262417024, 43.3647396381231, 43.3586539122512, 
             43.3067747933252, 43.3028463919537, 43.3757325102483, 43.3605667983998, 
             43.3584838474195, 43.3795731114911, 43.3236166758399, 43.3605899836471
    )), row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", 
                      "10", "11", "12", "13", "14", "15"), class = "data.frame")

    to <- structure(list(X = -8.413942, Y = 43.36652), class = "data.frame", row.names = "1")

    r <- route_dodgr(from, to, net = area99_sf)
#> unable to trace path number 10

    plot(r)

Created on 2019-07-15 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> ─ Session info ────────────────────────────────────────────────────────── #> setting value #> version R version 3.6.0 (2019-04-26) #> os Debian GNU/Linux 9 (stretch) #> system x86_64, linux-gnu #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Etc/UTC #> date 2019-07-15 #> #> ─ Packages ────────────────────────────────────────────────────────────── #> package * version date lib #> assertthat 0.2.1 2019-03-21 [1] #> backports 1.1.4 2019-04-10 [1] #> callr 3.3.0 2019-07-04 [1] #> class 7.3-15 2019-01-01 [2] #> classInt 0.3-3 2019-04-26 [1] #> cli 1.1.0 2019-03-19 [1] #> codetools 0.2-16 2018-12-24 [2] #> crayon 1.3.4 2017-09-16 [1] #> curl 3.3 2019-01-10 [1] #> DBI 1.0.0 2018-05-02 [1] #> desc 1.2.0 2018-05-01 [1] #> devtools 2.1.0 2019-07-06 [1] #> digest 0.6.20 2019-07-04 [1] #> dodgr 0.2.0.004 2019-07-15 [1] #> dplyr 0.8.3 2019-07-04 [1] #> e1071 1.7-2 2019-06-05 [1] #> evaluate 0.14 2019-05-28 [1] #> foreign 0.8-71 2018-07-20 [2] #> fs 1.3.1 2019-05-06 [1] #> geosphere 1.5-10 2019-05-26 [1] #> glue 1.3.1 2019-03-12 [1] #> highr 0.8 2019-03-20 [1] #> htmltools 0.3.6 2017-04-28 [1] #> httr 1.4.0 2018-12-11 [1] #> igraph 1.2.4.1 2019-04-22 [1] #> jsonlite 1.6 2018-12-07 [1] #> KernSmooth 2.23-15 2015-06-29 [2] #> knitr 1.23 2019-05-18 [1] #> lattice 0.20-38 2018-11-04 [2] #> lubridate 1.7.4 2018-04-11 [1] #> magrittr 1.5 2014-11-22 [1] #> maptools 0.9-5 2019-02-18 [1] #> memoise 1.1.0 2017-04-21 [1] #> mime 0.7 2019-06-11 [1] #> openxlsx 4.1.0.1 2019-05-28 [1] #> osmdata * 0.1.1 2019-05-22 [1] #> pillar 1.4.2 2019-06-29 [1] #> pkgbuild 1.0.3 2019-03-20 [1] #> pkgconfig 2.0.2 2018-08-16 [1] #> pkgload 1.0.2 2018-10-29 [1] #> prettyunits 1.0.2 2015-07-13 [1] #> processx 3.4.0 2019-07-03 [1] #> ps 1.3.0 2018-12-21 [1] #> purrr 0.3.2 2019-03-15 [1] #> R.methodsS3 1.7.1 2016-02-16 [1] #> R.oo 1.22.0 2018-04-22 [1] #> R.utils 2.9.0 2019-06-13 [1] #> R6 2.4.0 2019-02-14 [1] #> raster 2.9-5 2019-05-14 [1] #> Rcpp 1.0.1 2019-03-17 [1] #> RcppParallel 4.4.3 2019-05-22 [1] #> remotes 2.1.0 2019-06-24 [1] #> rgeos 0.4-3 2019-04-24 [1] #> rlang 0.4.0 2019-06-25 [1] #> rmarkdown 1.13 2019-05-22 [1] #> rprojroot 1.3-2 2018-01-03 [1] #> rvest 0.3.4 2019-05-15 [1] #> sessioninfo 1.1.1 2018-11-05 [1] #> sf * 0.7-6 2019-07-05 [1] #> sp 1.3-1 2018-06-05 [1] #> stplanr * 0.2.10.9000 2019-07-15 [1] #> stringi 1.4.3 2019-03-12 [1] #> stringr 1.4.0 2019-02-10 [1] #> testthat 2.1.1 2019-04-23 [1] #> tibble 2.1.3 2019-06-06 [1] #> tidyselect 0.2.5 2018-10-11 [1] #> units 0.6-3 2019-05-03 [1] #> usethis 1.5.1 2019-07-04 [1] #> withr 2.1.2 2018-03-15 [1] #> xfun 0.8 2019-06-25 [1] #> xml2 1.2.0 2018-01-24 [1] #> yaml 2.2.0 2018-07-25 [1] #> zip 2.0.3 2019-07-03 [1] #> source #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> Github (atfutures/dodgr@d8bf3fb) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> Github (mpadge/stplanr@a342489) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> #> [1] /usr/local/lib/R/site-library #> [2] /usr/local/lib/R/library ```
gert08 commented 5 years ago

In the reprex code I could not upload the whole file for a privacy issue, so I used a sample of 10 points to build from but in the complete file I have 288 points of which the function was only able to direct 222 to the point to, losing 66 paths. I don't know if I explained well now.

mpadge commented 5 years ago

@gert08 I've just done another tweak via #326 that should increase the number of successfully connecting paths - let us know, and/or do remotes::install_github("mpadge/stplanr") in case you want to try it before it gets merged here.

gert08 commented 5 years ago

@mpadge I keep getting the same results.

r=stplanr::route_dodgr(from,to, net = area99_sf)
#> unable to trace path number 103032335669798995108114115129131138150151159161166170179187189203238252253_
sessionInfo()
#> R version 3.6.0 (2019-04-26)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 17763)
#>
#> Matrix products: default
#>
#> Random number generation:
#> RNG:     Mersenne-Twister 
#> Normal:  Inversion 
#> Sample:  Rounding 
#>
#> locale:
#> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] reprex_0.3.0        dodgr_0.2.0.004     dplyr_0.8.3         osmdata_0.1.1      
#> [5] sf_0.7-6            stplanr_0.2.10.9000
#> 
#> loaded via a namespace (and not attached):
#> [1] httr_1.4.0         jsonlite_1.6       splines_3.6.0      R.utils_2.9.0     
#>  [5] RcppParallel_4.4.3 assertthat_0.2.1   sp_1.3-1           remotes_2.0.2     
#> [9] pillar_1.4.2       backports_1.1.4    lattice_0.20-38    glue_1.3.1        
#> [13] digest_0.6.20      rvest_0.3.4        htmltools_0.3.6    Matrix_1.2-17     
#> [17] R.oo_1.22.0        clipr_0.6.0        pkgconfig_2.0.2    raster_2.9-23     
#> [21] fda_2.4.8          purrr_0.3.2        processx_3.3.1     whisker_0.3-2     
#> [25] openxlsx_4.1.0.1   fda.usc_1.4.0      tibble_2.1.3       mgcv_1.8-28       
#> [29] withr_2.1.2        cli_1.1.0          magrittr_1.5       crayon_1.3.4      
#> [33] maptools_0.9-5     evaluate_0.12      ps_1.3.0           R.methodsS3_1.7.1 
#> [37] fs_1.2.6           plogr_0.2.0        nlme_3.1-139       MASS_7.3-51.4     
#> [41] xml2_1.2.0         foreign_0.8-71     class_7.3-15       pkgbuild_1.0.2    
#> [45] tools_3.6.0        prettyunits_1.0.2  geosphere_1.5-10   stringr_1.4.0     
#> [49] zip_2.0.3          callr_3.2.0        compiler_3.6.0     e1071_1.7-2       
#> [53] rlang_0.4.0        classInt_0.3-3     units_0.6-3        grid_3.6.0        
#> [57] rstudioapi_0.8     igraph_1.2.4.1     rmarkdown_1.10     codetools_0.2-16  
#> [61] DBI_1.0.0          curl_3.3           R6_2.4.0           lubridate_1.7.4   
#> [65] knitr_1.21         rgeos_0.4-3        rprojroot_1.3-2    KernSmooth_2.23-15
#> [69] stringi_1.4.3      Rcpp_1.0.1         rpart_4.1-15       tidyselect_0.2.5  
#> [73] xfun_0.4      

Created on 2019-07-16 by the reprex package (v0.3.0)

mpadge commented 5 years ago

@gert08 Not sure what you mean by same results? There may always be some paths that do connect if your submitted network itself does not fully connect (and even then untraceable paths may be theoretically possible because of such things as one-way restrictions). What you should see is a reduction in the number of untraceable paths; or (equivalently) an increase in the number of paths actually returned.

Can you also please include more reprex code for the above, and I'll use that to provide a more informative message that the one you've got above. (With your code as given above, both @Robinlovelace and I got only #> unable to trace path number 10, but it looks like you've got a bigger network there, or more from/to points, or both?) Thanks!

gert08 commented 5 years ago

@mpadge it's the same code, just like I said before, in the first I just used a sample of 10 points to build from but in the complete network I have 288 points of which the function was only able to direct 222 to the point to, losing 66 paths.

It's right, with the tweak #326 has increased to 226 the number of successfully connecting paths.

Robinlovelace commented 5 years ago

@gert08 thanks for the follow-up. Just to clarify: do you think that the function is still not working as it should?

gert08 commented 5 years ago

Yes, I think it's working. I will try to add more features to the over pass query object to see if I get more connected routes. Thank a lot for your work and help.

Robinlovelace commented 5 years ago

No problem @gert08, thank you for taking the time to test it and ask questions, which help hugely when developing a package.