ipeaGIT / r5r

https://ipeagit.github.io/r5r/
Other
179 stars 29 forks source link

Errror in costructing network with setup_r5() function #296

Closed Ramon-88 closed 2 years ago

Ramon-88 commented 2 years ago

Hello and congrats for this amazing library! I'm using r5r to create origin-destination travel time matrices. Apparently I have a problem in building the network with setup_r5() as each time I try to build my graph, although I got the network.dat, an error message comes to verbose console output:

Summarizing builder config: build-config.json { "htmlAnnotations" : false, "maxHtmlAnnotationsPerFile" : 1000, "transit" : true, "useTransfersTxt" : false, "parentStopLinking" : false, "stationTransfers" : false, "subwayAccessTime" : 2.0, "streets" : true, "embedRouterConfig" : true, "areaVisibility" : false, "matchBusRoutesToStreets" : false, "fetchElevationUS" : false, "speeds" : { "units" : "mph", "values" : { "secondary" : 35, "tertiary_link" : 25, "primary_link" : 25, "tertiary" : 25, "living_street" : 5, "motorway_link" : 35, "trunk" : 55, "secondary_link" : 25, "motorway" : 65, "trunk_link" : 35, "primary" : 45 }, "defaultSpeed" : 25 }, "staticBikeRental" : false, "staticParkAndRide" : true, "staticBikeParkAndRide" : false, "bikeRentalFile" : null, "analysisFareCalculator" : null }

[main] ERROR com.conveyal.r5.streets.StreetLayer - Continuing to load but ignoring generalized costs due to exception: java.lang.RuntimeException: All ways are expected to have generalized cost tags. Missing: slope_1:forward

I allocated more memory before executing library(r5r) by using options(java.parameters = '-Xmx2G') so I'm not sure why I got this error, I downloaded .pbf file from hot export tool website and BBBike.org website and also I tried wirh both small and big files but apparently nothing changed.

Do you have any idea why this happens? And mostly this error can affect the calculation of travel time distances?

Thanks in advance

rafapereirabr commented 2 years ago

could you please run sessionInfo() on your R session and paste the output in a comment below?

Ramon-88 commented 2 years ago

Yes sure and thanks for replying me:

sessionInfo() R version 4.1.2 (2021-11-01) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale: [1] LC_COLLATE=Italian_Italy.1252 LC_CTYPE=Italian_Italy.1252
[3] LC_MONETARY=Italian_Italy.1252 LC_NUMERIC=C
[5] LC_TIME=Italian_Italy.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] r5r_0.7.1 sp_1.5-0 stars_0.5-6 abind_1.4-5 tibble_3.1.8 areal_0.1.8 dplyr_1.0.10 [8] tmap_3.3-3 sf_1.0-8

loaded via a namespace (and not attached): [1] tidyselect_1.1.2 terra_1.6-17 purrr_0.3.4 rJava_1.0-6
[5] lattice_0.20-45 vctrs_0.4.2 generics_0.1.3 htmltools_0.5.3
[9] viridisLite_0.4.1 base64enc_0.1-3 utf8_1.2.2 XML_3.99-0.10
[13] rlang_1.0.6 e1071_1.7-11 pillar_1.8.1 glue_1.6.2
[17] DBI_1.1.3 RColorBrewer_1.1-3 lifecycle_1.0.2 raster_3.6-3
[21] htmlwidgets_1.5.4 leafsync_0.1.0 codetools_0.2-18 fastmap_1.1.0
[25] crosstalk_1.2.0 curl_4.3.2 parallel_4.1.2 class_7.3-19
[29] fansi_1.0.3 leafem_0.2.0 Rcpp_1.0.9 KernSmooth_2.23-20 [33] backports_1.4.1 checkmate_2.1.0 classInt_0.4-8 lwgeom_0.2-9
[37] leaflet_2.1.1 png_0.1-7 digest_0.6.29 tmaptools_3.1-1
[41] grid_4.1.2 rgdal_1.5-32 cli_3.4.1 tools_4.1.2
[45] magrittr_2.0.3 proxy_0.4-27 dichromat_2.0-0.1 pkgconfig_2.0.3
[49] ellipsis_0.3.2 data.table_1.14.2 assertthat_0.2.1 rstudioapi_0.14
[53] R6_2.5.1 units_0.8-0 compiler_4.1.2

For completeness I also past a warning message that I got from the console, just below the error message. With respect to this I searched online and apparently this shouldn't be problematic:

[main] ERROR com.conveyal.r5.streets.StreetLayer - Continuing to load but ignoring generalized costs due to exception: java.lang.RuntimeException: All ways are expected to have generalized cost tags. Missing: slope_1:forward WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.esotericsoftware.kryo.util.UnsafeUtil (file:/C:/Users/OneDrive/Documents/R/win-library/4.1/r5r/jar/r5-v6.4-all.jar) to constructor java.nio.DirectByteBuffer(long,int,java.lang.Object) WARNING: Please consider reporting this to the maintainers of com.esotericsoftware.kryo.util.UnsafeUtil WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release

rafapereirabr commented 2 years ago

could you please run the example below to see if the problem persists?

Start fresh R session

# allocate RAM memory to Java
options(java.parameters = "-Xmx2G")

# 1) build transport network, pointing to the path where OSM and GTFS data are stored
library(r5r)
path <- system.file("extdata/poa", package = "r5r")
r5r_core <- setup_r5(data_path = path, verbose = FALSE)

# 2) load origin/destination points and set arguments
points <- read.csv(system.file("extdata/poa/poa_hexgrid.csv", package = "r5r"))
mode <- c("WALK", "TRANSIT")
max_walk_time <- 30   # minutes
max_trip_duration <- 60 # minutes
departure_datetime <- as.POSIXct("13-05-2019 14:00:00",
                                 format = "%d-%m-%Y %H:%M:%S")

# 3.1) calculate a travel time matrix
ttm <- travel_time_matrix(r5r_core = r5r_core,
                          origins = points,
                          destinations = points,
                          mode = mode,
                          departure_datetime = departure_datetime,
                          max_walk_time = max_walk_time,
                          max_trip_duration = max_trip_duration)

head(ttm)
Ramon-88 commented 2 years ago

Starting a fresh R session and running your first part of code:

# allocate RAM memory to Java options(java.parameters = "-Xmx2G")

# 1) build transport network, pointing to the path where OSM and GTFS data are stored library(r5r) path <- system.file("extdata/poa", package = "r5r") r5r_core <- setup_r5(data_path = path, verbose = FALSE)

I got this result:

Downloading R5 jar file to C:/Users/###/OneDrive/Documents/R/win-library/4.1/r5r/jar/r5-v6.7-all.jar 2022-10-10 17:53:11,889 [main] ERROR c.c.r.s.StreetLayer - Continuing to load but ignoring generalized costs due to exception: java.lang.RuntimeException: All ways are expected to have generalized cost tags. Missing: slope_1:forward WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.mapdb.Volume$ByteBufferVol (file:/C:/Users/###/OneDrive/Documents/R/win-library/4.1/r5r/jar/r5-v6.7-all.jar) to method java.nio.DirectByteBuffer.cleaner() WARNING: Please consider reporting this to the maintainers of org.mapdb.Volume$ByteBufferVol WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release ott 10, 2022 5:53:19 PM org.hsqldb.persist.Logger logInfoEvent INFO: dataFileCache open start

Finished building network.dat at C:/Users/###/OneDrive/Documents/R/win-library/4.1/r5r/extdata/poa/network.dat

rafapereirabr commented 2 years ago

What version of Java do you have installed on your comuter? Please bear in mind that you need to have Java SE Development Kit 11 installed on your computer to use r5r. The JDK v11.0.10 is freely available from the options below:

Ramon-88 commented 2 years ago

I followed all the instructions reported in the section "Installation" so I already downloaded the suggested version of Java from the link you sent me now. Anyway by running rJava::.jcall("java.lang.System", "S", "getProperty", "java.version") it returns the following version: "11.0.16.1"

rafapereirabr commented 2 years ago

please try running r5r::download_r5(force_update = T) and then try running the code of the example

Ramon-88 commented 2 years ago

I just did it and unfortunately it returns me the same error/warnings messages as before

rafapereirabr commented 2 years ago

I followed all the instructions reported in the section "Installation" so I already downloaded the suggested version of Java from the link you sent me now. Anyway by running rJava::.jcall("java.lang.System", "S", "getProperty", "java.version") it returns the following version: "11.0.16.1"

this is probably the problem. Please install JDK v11.0.10 and try again

Ramon-88 commented 2 years ago

I tried again by using first JDK v11.0.10 and then JDK v11 downloaded here: https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html but unfortunately nothing changed. I was thinking to use another laptop to try if it works or not as maybe there is something on my laptop that is affecting the process.

rafapereirabr commented 2 years ago

have you uninstalled java 11.0.16.1 ? Please sure to check what Java version your R is picking up.

run

rJava::.jinit()
rJava::.jcall("java.lang.System", "S", "getProperty", "java.version")

the output should be "11.0.10"

Ramon-88 commented 2 years ago

I did what you suggested. To be sure I uninstalled java 11.0.16.1 and then restarted windows before doing the new installation after that I checked and got this output "11.0.10", but still when I run the example I got the same error/warnings. Just for curiosity I tried to run also this example (https://www.urbandemographics.org/post/r5r-fast-multimodal-transport-routing-in-r/) and despite I got the same problems, checking the first lines of the output head(ttm) they corresponded to the results I got. I was just wondering if this error/results really affects the creation of the network and so the analysis itself.

rafapereirabr commented 2 years ago

Hi @Ramon-88 . R5 does throw some error/warnings messages which, as a rule, are not critical to the creation of the network. If you're getting the same results from the example you mentioned, then everything is working fine. Closing this issue for now.

Ramon-88 commented 2 years ago

Got it, thanks for your availability!