dabreegster / odjitter

Disaggregate zone-based origin/destination data to specific points
Apache License 2.0
12 stars 6 forks source link

R odjitter in Windows #27

Closed temospena closed 2 years ago

temospena commented 2 years ago

Hi,

In Win 10, there is apparently an error of reading/writing the temporary od_jittered.geojson file.

library(od) #just to get a small data input
library(odjitter)
#> 
#> Attaching package: 'odjitter'
#> The following object is masked from 'package:base':
#> 
#>     jitter

od_all_jittered = odjitter::jitter(
  od = od_data_df,
  zones = od_data_zones_min,
  subpoints = sf::st_sample(od_data_zones_min, 200)
)
#> Warning in system(msg): 'odjitter' not found
#> Error: Cannot open "C:\Users\UTILIZ~1\AppData\Local\Temp\RtmpeWTALa/od_jittered.geojson"; The file doesn't seem to exist.

Created on 2022-03-25 by the reprex package (v2.0.1)

The error is persistent between runs/data input.

Error: Cannot open "C:\Users\UTILIZ~1\AppData\Local\Temp\RtmpC08uIU/od_jittered.geojson"; The file doesn't seem to exist.

Robinlovelace commented 2 years ago

Looks like a quick fix file location issue, will test on my new Windows laptop and report back...

Robinlovelace commented 2 years ago

I can reproduce this isse:

od_jittered = jitter(od, zones, subpoints = road_network)
Error: Cannot open "C:\Users\ROBINA~1\AppData\Local\Temp\Rtmp6TXMlr/od_jittered.geojson"; The file doesn't seem to exist.
Robinlovelace commented 2 years ago

Update: it seems the odjitter CLI is not working on windows, not a file path issue.

Robinlovelace commented 2 years ago

Good news, it's fixed for me 🎉

Heads-up @temospena it was fixed after double checking the installation on PowerShell, I guess there's some issue with the installation, basically R cannot 'see' the odjitter command for some reason. I plan to add a check to see if it has access to that...

Robinlovelace commented 2 years ago

Can you try this Rosa?:

system("odjitter --help")
odjitter 0.1.0
Dustin Carlino <dabreegster@gmail.com
Disaggregate origin/destination data from zones to points
Robinlovelace commented 2 years ago

Pls try reinstalling the R package, you should get a meaningfull message now...

temospena commented 2 years ago

Thanks!

Reinstalled the R package with remotes::install_github("dabreegster/odjitter", subdir = "r") [not in documentation]

You're right, another message shows up!

library(od)
library(odjitter)
#> 
#> Attaching package: 'odjitter'
#> The following object is masked from 'package:base':
#> 
#>     jitter

od_all_jittered = odjitter::jitter(
  od = od_data_df,
  zones = od_data_zones_min,
  subpoints = sf::st_sample(od_data_zones_min, 200)
)
#> Error in system("odjitter --help", intern = TRUE): 'odjitter' not found

Created on 2022-03-26 by the reprex package (v2.0.1)

Session info ``` r sessionInfo() #> R version 4.0.4 (2021-02-15) #> Platform: x86_64-w64-mingw32/x64 (64-bit) #> Running under: Windows 10 x64 (build 19044) #> #> Matrix products: default #> #> locale: #> [1] LC_COLLATE=Portuguese_Portugal.1252 LC_CTYPE=Portuguese_Portugal.1252 #> [3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C #> [5] LC_TIME=Portuguese_Portugal.1252 #> #> attached base packages: #> [1] stats graphics grDevices utils datasets methods base #> #> other attached packages: #> [1] odjitter_0.0.0.9000 od_0.3.2 #> #> loaded via a namespace (and not attached): #> [1] digest_0.6.29 withr_2.5.0 magrittr_2.0.2 reprex_2.0.1 #> [5] evaluate_0.15 highr_0.9 stringi_1.7.6 rlang_1.0.2 #> [9] cli_3.0.0 rstudioapi_0.13 fs_1.5.2 rmarkdown_2.13 #> [13] tools_4.0.4 stringr_1.4.0 glue_1.6.2 xfun_0.30 #> [17] yaml_2.3.5 fastmap_1.1.0 compiler_4.0.4 htmltools_0.5.2 #> [21] knitr_1.37 ```

Although the package is installed and available.

temospena commented 2 years ago

remotes::install_github("dabreegster/odjitter", subdir = "r") [not in documentation]

nevermind, just found it under the r folder! sorry 😅

Robinlovelace commented 2 years ago

Does it work now?

temospena commented 2 years ago

No. In windows I'm facing the same issue. Error in system("odjitter --help", intern = TRUE) : 'odjitter' not found

In ubuntu it works fine.

Robinlovelace commented 2 years ago

That sounds like an issue with the odjitter CLI tool not being installed on PowerShell...

temospena commented 2 years ago

Right! Sorry, it was not clear to me that cargo / odjitter needed to be installed first (never used PowerShell before).

library(od)
library(odjitter)
#> 
#> Attaching package: 'odjitter'
#> The following object is masked from 'package:base':
#> 
#>     jitter

od_all_jittered = odjitter::jitter(
  od = od_data_df,
  zones = od_data_zones_min,
  subpoints = sf::st_sample(od_data_zones_min, 200)
)

Scraped 6 zones from C:\Users\UTILIZ~1\AppData\Local\Temp\RtmpATZ0OL/zones.geojson
Scraped 200 subpoints from C:\Users\UTILIZ~1\AppData\Local\Temp\RtmpATZ0OL/subpoints.geojson
Scraped 200 subpoints from C:\Users\UTILIZ~1\AppData\Local\Temp\RtmpATZ0OL/subpoints.geojson
Disaggregating OD data
Wrote C:\Users\UTILIZ~1\AppData\Local\Temp\RtmpATZ0OL/od_jittered.geojson

Created on 2022-04-07 by the reprex package (v2.0.1)

Working fine now!

Robinlovelace commented 2 years ago

🎉