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

street_network_to_sf() with different results in windows and ubuntu #297

Closed
temospena opened this issue Oct 20, 2022 · 1 comment
Closed

Comments

@temospena
Copy link

Hi,
I think I'm facing a bug issue with the street_network_to_sf() function.

Brief description of the problem:

When getting the edges of the built r5r network, in Windows it does not come with osm_id, edge_index, street_class variables.

But in Ubuntu, it does, and a couple more information.

See the structure of the results with that function, for Windows and Ubuntu.

I believe i'm using the same dev version of r5r.

Is this a result from #290 that was not implemented on windows version yet?

Thank you!

Reproducible example here

Using Windows (10)

library(dplyr)
#> 
#> 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)
#> Linking to GEOS 3.9.1, GDAL 3.4.3, PROJ 7.2.1; sf_use_s2() is TRUE
options(java.parameters = '-Xmx4G')
library(r5r)
#> Please make sure you have already allocated some memory to Java by running:
#>   options(java.parameters = '-Xmx2G').
#> You should replace '2G' by the amount of memory you'll require. Currently, Java memory is set to -Xmx4G

data_path = system.file("extdata/poa", package = "r5r")
r5r_demo = setup_r5(data_path, verbose = FALSE)
#> Using cached R5 version from C:/Users/Utilizador/AppData/Local/R/win-library/4.2/r5r/jar/r5-v6.7-all.jar
#> 
#> Using cached network.dat from C:/Users/Utilizador/AppData/Local/R/win-library/4.2/r5r/extdata/poa/network.dat

r5r_demo_shp = street_network_to_sf(r5r_demo)
str(r5r_demo_shp)
#> List of 2
#>  $ vertices:Classes 'sf' and 'data.frame':   22637 obs. of  4 variables:
#>   ..$ index        : int [1:22637] 0 1 2 3 4 5 6 7 8 9 ...
#>   ..$ park_and_ride: logi [1:22637] FALSE FALSE FALSE FALSE FALSE FALSE ...
#>   ..$ bike_sharing : logi [1:22637] FALSE FALSE FALSE FALSE FALSE FALSE ...
#>   ..$ geometry     :sfc_POINT of length 22637; first list element:  'XY' num [1:2] -51.2 -30.1
#>   ..- attr(*, "sf_column")= chr "geometry"
#>  $ edges   :Classes 'sf', 'data.table' and 'data.frame': 60986 obs. of  8 variables:
#>   ..$ from_vertex: int [1:60986] 0 1 1 2 3 4 4 5 5 6 ...
#>   ..$ to_vertex  : int [1:60986] 1 0 2 1 4 3 5 4 6 5 ...
#>   ..$ length     : num [1:60986] 27.2 27.2 79.4 79.4 81.4 ...
#>   ..$ car        : logi [1:60986] TRUE FALSE TRUE FALSE TRUE FALSE ...
#>   ..$ walk       : logi [1:60986] TRUE TRUE TRUE TRUE TRUE TRUE ...
#>   ..$ bicycle    : logi [1:60986] TRUE FALSE TRUE FALSE TRUE FALSE ...
#>   ..$ bicycle_lts: int [1:60986] 4 4 4 4 4 4 4 4 4 4 ...
#>   ..$ geometry   :sfc_LINESTRING of length 60986; first list element:  'XY' num [1:2, 1:2] -51.2 -51.2 -30.1 -30.1
#>   ..- attr(*, "sf_column")= chr "geometry"
#>   ..- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA
#>   .. ..- attr(*, "names")= chr [1:7] "from_vertex" "to_vertex" "length" "car" ...

Created on 2022-10-20 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.1 RC (2022-06-17 r82506 ucrt)
#>  os       Windows 10 x64 (build 19044)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  Portuguese_Portugal.utf8
#>  ctype    Portuguese_Portugal.utf8
#>  tz       Europe/London
#>  date     2022-10-20
#>  pandoc   2.17.1.1 @ C:/Program Files/RStudio/bin/quarto/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version  date (UTC) lib source
#>    assertthat    0.2.1    2019-03-21 [1] CRAN (R 4.2.0)
#>    backports     1.4.1    2021-12-13 [1] CRAN (R 4.2.0)
#>    checkmate     2.1.0    2022-04-21 [1] CRAN (R 4.2.0)
#>    class         7.3-20   2022-01-16 [2] CRAN (R 4.2.1)
#>    classInt      0.4-7    2022-06-10 [1] CRAN (R 4.2.0)
#>    cli           3.3.0    2022-04-25 [1] CRAN (R 4.2.0)
#>    data.table    1.14.2   2021-09-27 [1] CRAN (R 4.2.0)
#>    DBI           1.1.3    2022-06-18 [1] CRAN (R 4.2.0)
#>    digest        0.6.29   2021-12-01 [1] CRAN (R 4.2.0)
#>    dplyr       * 1.0.9    2022-04-28 [1] CRAN (R 4.2.0)
#>    e1071         1.7-11   2022-06-07 [1] CRAN (R 4.2.0)
#>    ellipsis      0.3.2    2021-04-29 [1] CRAN (R 4.2.0)
#>    evaluate      0.16     2022-08-09 [1] CRAN (R 4.2.1)
#>    fansi         1.0.3    2022-03-24 [1] CRAN (R 4.2.0)
#>    fastmap       1.1.0    2021-01-25 [1] CRAN (R 4.2.0)
#>    fs            1.5.2    2021-12-08 [1] CRAN (R 4.2.0)
#>    generics      0.1.3    2022-07-05 [1] CRAN (R 4.2.1)
#>    glue          1.6.2    2022-02-24 [1] CRAN (R 4.2.0)
#>    highr         0.9      2021-04-16 [1] CRAN (R 4.2.0)
#>    htmltools     0.5.2    2021-08-25 [1] CRAN (R 4.2.0)
#>    KernSmooth    2.23-20  2021-05-03 [2] CRAN (R 4.2.1)
#>    knitr         1.40     2022-08-24 [1] CRAN (R 4.2.1)
#>    lifecycle     1.0.1    2021-09-24 [1] CRAN (R 4.2.0)
#>    magrittr      2.0.3    2022-03-30 [1] CRAN (R 4.2.0)
#>    pillar        1.8.1    2022-08-19 [1] CRAN (R 4.2.1)
#>    pkgconfig     2.0.3    2019-09-22 [1] CRAN (R 4.2.0)
#>    proxy         0.4-27   2022-06-09 [1] CRAN (R 4.2.0)
#>    purrr         0.3.4    2020-04-17 [1] CRAN (R 4.2.0)
#>    R.cache       0.16.0   2022-07-21 [1] CRAN (R 4.2.1)
#>    R.methodsS3   1.8.2    2022-06-13 [1] CRAN (R 4.2.0)
#>    R.oo          1.25.0   2022-06-12 [1] CRAN (R 4.2.0)
#>    R.utils       2.12.0   2022-06-28 [1] CRAN (R 4.2.1)
#>    r5r         * 0.7.9000 2022-06-21 [1] Github (ipeaGIT/r5r@bf83698)
#>    R6            2.5.1    2021-08-19 [1] CRAN (R 4.2.0)
#>    Rcpp          1.0.8.3  2022-03-17 [1] CRAN (R 4.2.0)
#>    reprex        2.0.2    2022-08-17 [1] CRAN (R 4.2.1)
#>  D rJava         1.0-6    2021-12-10 [1] CRAN (R 4.2.0)
#>    rlang         1.0.3    2022-06-27 [1] CRAN (R 4.2.1)
#>    rmarkdown     2.16     2022-08-24 [1] CRAN (R 4.2.1)
#>    rstudioapi    0.14     2022-08-22 [1] CRAN (R 4.2.1)
#>    sessioninfo   1.2.2    2021-12-06 [1] CRAN (R 4.2.0)
#>    sf          * 1.0-8    2022-07-14 [1] CRAN (R 4.2.1)
#>    sfheaders     0.4.0    2020-12-01 [1] CRAN (R 4.2.0)
#>    stringi       1.7.8    2022-07-11 [1] CRAN (R 4.2.1)
#>    stringr       1.4.1    2022-08-20 [1] CRAN (R 4.2.1)
#>    styler        1.7.0    2022-03-13 [1] CRAN (R 4.2.0)
#>    tibble        3.1.7    2022-05-03 [1] CRAN (R 4.2.0)
#>    tidyselect    1.1.2    2022-02-21 [1] CRAN (R 4.2.0)
#>    units         0.8-0    2022-02-05 [1] CRAN (R 4.2.0)
#>    utf8          1.2.2    2021-07-24 [1] CRAN (R 4.2.0)
#>    vctrs         0.4.1    2022-04-13 [1] CRAN (R 4.2.0)
#>    withr         2.5.0    2022-03-03 [1] CRAN (R 4.2.0)
#>    xfun          0.32     2022-08-10 [1] CRAN (R 4.2.1)
#>    yaml          2.3.5    2022-02-21 [1] CRAN (R 4.2.0)
#> 
#>  [1] C:/Users/Utilizador/AppData/Local/R/win-library/4.2
#>  [2] C:/Program Files/R/R-4.2.1rc/library
#> 
#>  D ── DLL MD5 mismatch, broken installation.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Using Ubuntu (Kubuntu 22)

library(dplyr)
#> 
#> 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)
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
options(java.parameters = '-Xmx4G')
library(r5r)
#> Please make sure you have already allocated some memory to Java by running:
#>   options(java.parameters = '-Xmx2G').
#> You should replace '2G' by the amount of memory you'll require. Currently, Java memory is set to -Xmx4G

data_path = system.file("extdata/poa", package = "r5r")
r5r_demo = setup_r5(data_path, verbose = FALSE)
#> Using cached R5 version from /home/rosa/R/x86_64-pc-linux-gnu-library/4.1/r5r/jar/r5-v6.7-all.jar
#> 
#> Using cached network.dat from /home/rosa/R/x86_64-pc-linux-gnu-library/4.1/r5r/extdata/poa/network.dat

r5r_demo_shp = street_network_to_sf(r5r_demo)
str(r5r_demo_shp)
#> List of 2
#>  $ vertices:Classes 'sf' and 'data.frame':   22637 obs. of  4 variables:
#>   ..$ index        : int [1:22637] 0 1 2 3 4 5 6 7 8 9 ...
#>   ..$ park_and_ride: logi [1:22637] FALSE FALSE FALSE FALSE FALSE FALSE ...
#>   ..$ bike_sharing : logi [1:22637] FALSE FALSE FALSE FALSE FALSE FALSE ...
#>   ..$ geometry     :sfc_POINT of length 22637; first list element:  'XY' num [1:2] -51.2 -30.1
#>   ..- attr(*, "sf_column")= chr "geometry"
#>  $ edges   :Classes 'sf', 'data.table' and 'data.frame': 60986 obs. of  12 variables:
#>   ..$ edge_index  : int [1:60986] 0 1 2 3 4 5 6 7 8 9 ...
#>   ..$ osm_id      : num [1:60986] 26786712 26786712 26786712 26786712 26786730 ...
#>   ..$ from_vertex : int [1:60986] 0 1 1 2 3 4 4 5 5 6 ...
#>   ..$ to_vertex   : int [1:60986] 1 0 2 1 4 3 5 4 6 5 ...
#>   ..$ street_class: chr [1:60986] "PRIMARY" "PRIMARY" "PRIMARY" "PRIMARY" ...
#>   ..$ length      : num [1:60986] 27.2 27.2 79.4 79.4 81.4 ...
#>   ..$ walk        : logi [1:60986] TRUE TRUE TRUE TRUE TRUE TRUE ...
#>   ..$ car         : logi [1:60986] TRUE FALSE TRUE FALSE TRUE FALSE ...
#>   ..$ car_speed   : num [1:60986] 60 60 60 60 60 ...
#>   ..$ bicycle     : logi [1:60986] TRUE FALSE TRUE FALSE TRUE FALSE ...
#>   ..$ bicycle_lts : int [1:60986] 4 4 4 4 4 4 4 4 4 4 ...
#>   ..$ geometry    :sfc_LINESTRING of length 60986; first list element:  'XY' num [1:2, 1:2] -51.2 -51.2 -30.1 -30.1
#>   ..- attr(*, "sf_column")= chr "geometry"
#>   ..- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
#>   .. ..- attr(*, "names")= chr [1:11] "edge_index" "osm_id" "from_vertex" "to_vertex" ...

Created on 2022-10-20 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.1.2 (2021-11-01)
#>  os       Ubuntu 22.04.1 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    pt_PT.UTF-8
#>  tz       Europe/Lisbon
#>  date     2022-10-20
#>  pandoc   2.19.2 @ /usr/lib/rstudio/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version   date (UTC) lib source
#>  assertthat    0.2.1     2019-03-21 [1] CRAN (R 4.1.2)
#>  backports     1.4.1     2021-12-13 [1] CRAN (R 4.1.2)
#>  checkmate     2.1.0     2022-04-21 [1] CRAN (R 4.1.2)
#>  class         7.3-20    2022-01-13 [4] CRAN (R 4.1.2)
#>  classInt      0.4-8     2022-09-29 [1] CRAN (R 4.1.2)
#>  cli           3.4.1     2022-09-23 [1] CRAN (R 4.1.2)
#>  data.table    1.14.4    2022-10-17 [1] CRAN (R 4.1.2)
#>  DBI           1.1.3     2022-06-18 [1] CRAN (R 4.1.2)
#>  digest        0.6.29    2021-12-01 [1] CRAN (R 4.1.2)
#>  dplyr       * 1.0.10    2022-09-01 [1] CRAN (R 4.1.2)
#>  e1071         1.7-11    2022-06-07 [1] CRAN (R 4.1.2)
#>  evaluate      0.17      2022-10-07 [1] CRAN (R 4.1.2)
#>  fansi         1.0.3     2022-03-24 [1] CRAN (R 4.1.2)
#>  fastmap       1.1.0     2021-01-25 [1] CRAN (R 4.1.2)
#>  fs            1.5.2     2021-12-08 [1] CRAN (R 4.1.2)
#>  generics      0.1.3     2022-07-05 [1] CRAN (R 4.1.2)
#>  glue          1.6.2     2022-02-24 [1] CRAN (R 4.1.2)
#>  highr         0.9       2021-04-16 [1] CRAN (R 4.1.2)
#>  htmltools     0.5.3     2022-07-18 [1] CRAN (R 4.1.2)
#>  KernSmooth    2.23-20   2021-05-03 [4] CRAN (R 4.0.4)
#>  knitr         1.40      2022-08-24 [1] CRAN (R 4.1.2)
#>  lifecycle     1.0.3     2022-10-07 [1] CRAN (R 4.1.2)
#>  magrittr      2.0.3     2022-03-30 [1] CRAN (R 4.1.2)
#>  pillar        1.8.1     2022-08-19 [1] CRAN (R 4.1.2)
#>  pkgconfig     2.0.3     2019-09-22 [1] CRAN (R 4.1.2)
#>  proxy         0.4-27    2022-06-09 [1] CRAN (R 4.1.2)
#>  r5r         * 0.7.90000 2022-10-19 [1] Github (ipeaGIT/r5r@e463766)
#>  R6            2.5.1     2021-08-19 [1] CRAN (R 4.1.2)
#>  Rcpp          1.0.9     2022-07-08 [1] CRAN (R 4.1.2)
#>  reprex        2.0.2     2022-08-17 [1] CRAN (R 4.1.2)
#>  rJava         1.0-6     2021-12-10 [3] CRAN (R 4.1.2)
#>  rlang         1.0.6     2022-09-24 [1] CRAN (R 4.1.2)
#>  rmarkdown     2.17      2022-10-07 [1] CRAN (R 4.1.2)
#>  rstudioapi    0.14      2022-08-22 [1] CRAN (R 4.1.2)
#>  sessioninfo   1.2.2     2021-12-06 [1] CRAN (R 4.1.2)
#>  sf          * 1.0-8     2022-07-14 [1] CRAN (R 4.1.2)
#>  sfheaders     0.4.0     2020-12-01 [1] CRAN (R 4.1.2)
#>  stringi       1.7.8     2022-07-11 [1] CRAN (R 4.1.2)
#>  stringr       1.4.1     2022-08-20 [1] CRAN (R 4.1.2)
#>  tibble        3.1.8     2022-07-22 [1] CRAN (R 4.1.2)
#>  tidyselect    1.2.0     2022-10-10 [1] CRAN (R 4.1.2)
#>  units         0.8-0     2022-02-05 [1] CRAN (R 4.1.2)
#>  utf8          1.2.2     2021-07-24 [1] CRAN (R 4.1.2)
#>  vctrs         0.4.2     2022-09-29 [1] CRAN (R 4.1.2)
#>  withr         2.5.0     2022-03-03 [1] CRAN (R 4.1.2)
#>  xfun          0.33      2022-09-12 [1] CRAN (R 4.1.2)
#>  yaml          2.3.5     2022-02-21 [1] CRAN (R 4.1.2)
#> 
#>  [1] /home/rosa/R/x86_64-pc-linux-gnu-library/4.1
#>  [2] /usr/local/lib/R/site-library
#>  [3] /usr/lib/R/site-library
#>  [4] /usr/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────
@temospena
Copy link
Author

Apparently it was only a matter to update Win version to the latest dev r5r package
Sorry for this, closing now.

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