{"id":15292983,"url":"https://github.com/ipeagit/r5r","last_synced_at":"2025-04-08T09:06:38.524Z","repository":{"id":37496824,"uuid":"285653536","full_name":"ipeaGIT/r5r","owner":"ipeaGIT","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-23T07:37:11.000Z","size":106382,"stargazers_count":187,"open_issues_count":31,"forks_count":32,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-08T09:06:30.872Z","etag":null,"topics":["gtfs","java","r","r5","router","routing","transport","transport-networks"],"latest_commit_sha":null,"homepage":"https://ipeagit.github.io/r5r/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ipeaGIT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-06T19:24:09.000Z","updated_at":"2025-03-28T13:18:17.000Z","dependencies_parsed_at":"2023-11-23T23:22:03.832Z","dependency_job_id":"bdb9fba6-9fb0-4730-956b-395c56e70159","html_url":"https://github.com/ipeaGIT/r5r","commit_stats":{"total_commits":1501,"total_committers":13,"mean_commits":"115.46153846153847","dds":0.5769487008660893,"last_synced_commit":"37fe8c6ee0a17be630029590efe6ff7c50830647"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipeaGIT%2Fr5r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipeaGIT%2Fr5r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipeaGIT%2Fr5r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipeaGIT%2Fr5r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ipeaGIT","download_url":"https://codeload.github.com/ipeaGIT/r5r/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247809964,"owners_count":20999816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gtfs","java","r","r5","router","routing","transport","transport-networks"],"created_at":"2024-09-30T16:36:50.654Z","updated_at":"2025-04-08T09:06:38.493Z","avatar_url":"https://github.com/ipeaGIT.png","language":"R","readme":"# r5r: Rapid Realistic Routing with R5 in R \u003cimg align=\"right\" src=\"r-package/man/figures/r5r_blue.png\" alt=\"logo\" width=\"180\"\u003e\n\n[![CRAN/METACRAN Version](https://www.r-pkg.org/badges/version/r5r)](https://CRAN.R-project.org/package=r5r)\n[![CRAN/METACRAN Total downloads](https://cranlogs.r-pkg.org/badges/grand-total/r5r?color=blue)](https://CRAN.R-project.org/package=r5r)\n[![R build status](https://github.com/ipeaGIT/r5r/workflows/R-CMD-check/badge.svg)](https://github.com/ipeaGIT/r5r/actions)\n[![Codecov test coverage](https://codecov.io/gh/ipeaGIT/r5r/branch/master/graph/badge.svg)](https://app.codecov.io/gh/ipeaGIT/r5r?branch=master)\n[![Lifecycle: maturing](https://lifecycle.r-lib.org/articles/figures/lifecycle-maturing.svg)](https://lifecycle.r-lib.org/articles/stages.html)\n[![Publication](https://img.shields.io/badge/DOI-10.32866%2F001c.21262-yellow)](https://doi.org/10.32866/001c.21262)\n\n**r5r** is an `R` package for rapid realistic routing on multimodal transport \nnetworks (walk, bike, public transport and car). It provides a simple and \nfriendly interface to R\u003csup\u003e5\u003c/sup\u003e, the [Rapid Realistic Routing on Real-world and Reimagined networks](https://github.com/conveyal/r5), the routing engine developed independently by [Conveyal](http://conveyal.com).\n\n**r5r** is a simple way to run R\u003csup\u003e5\u003c/sup\u003e locally, allowing `R` users to\ngenerate detailed routing analysis or calculate travel time matrices and \naccessibility using seamless parallel computing. See a detailed demonstration of\n`r5r` in the [intro Vignette](https://ipeagit.github.io/r5r/articles/r5r.html).\nMore details about **r5r** can be found on the [package webpage](https://ipeagit.github.io/r5r/index.html) or on this [paper](\nhttps://doi.org/10.32866/001c.21262). Over time, `r5r` might be expanded to \nincorporate other functionality from R\u003csup\u003e5\u003c/sup\u003e.\n\nThis repository contains the `R` code (r-package folder) and the Java code \n(java-api folder) that provides the interface to R\u003csup\u003e5\u003c/sup\u003e.\n\n## Installation\n\nYou can install `r5r`:\n\n```R\n# from CRAN\ninstall.packages(\"r5r\")\n\n# dev version with latest features\nutils::remove.packages('r5r')\ndevtools::install_github(\"ipeaGIT/r5r\", subdir = \"r-package\")\n\n```\n\nPlease bear in mind that you need to have *Java Development Kit (JDK) 21* installed on your computer to use `r5r`. No worries, you don't have to pay for it. There are numerous open-source JDK implementations, any of which should work with `r5r`. If you don't already have a preferred JDK, we recommend [Adoptium/Eclipse Temurin](https://adoptium.net/). Other open-source JDK implementations include [Amazon Corretto](https://aws.amazon.com/corretto/), and [Oracle OpenJDK](https://jdk.java.net/21/). You only need to install one JDK.\n\nThe easiest way to install JDK is using the new [{rJavaEnv}](https://www.ekotov.pro/rJavaEnv/) package in R:\n\n```R\n# install.packages('rJavaEnv')\n\n# check version of Java currently installed (if any) \nrJavaEnv::java_check_version_rjava()\n\n# install Java 21\nrJavaEnv::java_quick_install(version = 21)\n\n```\n\n## Usage\n\nThe package has seven **fundamental functions**:\n\n1. `setup_r5()`\n   * Downloads and stores locally an R5 Jar file (the Jar file is downloaded only \n   once per installation)\n   * Builds a multimodal transport network given (1) a OpenStreetMap street network in `.pbf`\n   format (*mandatory*), (2) one or more public transport networks in `GTFS.zip`\n   format  (optional), and (3) elevation data in `raster.tif` (optional).\n\n2. `accessibility()`\n   * Fast computation of access to opportunities. The function returns a \n   `data.table` with accessibility estimates for all origin points by transport \n   mode given a selected decay function. Multiple decay functions are available,\n   including step (cumulative opportunities), logistic, fixed exponential and \n   linear.\n\n3. `travel_time_matrix()`\n   * Fast function that returns a simple `data.table` with travel time estimates\n   between one or multiple origin destination pairs.\n\n4. `expanded_travel_time_matrix()`\n   * Calculates travel time matrices between origin destination pairs with \n   additional information such as routes used and total time disaggregated by access, \n   waiting, in-vehicle and transfer times.\n\n5. `detailed_itineraries()`\n   * Returns a `data.frame sf LINESTRINGs` with one or multiple alternative routes\n   between one or multiple origin destination pairs. The data output brings \n   detailed information on transport mode, travel time, walk distance etc for \n   each trip segment.\n\n6. `pareto_frontier()`\n   * Returns a `data.table` with the travel time and monetary cost of multiple\n   route alternatives for specified origin-destination pairs.\n   \n7. `isochrone()`\n   * Returns a `A ⁠POLYGON  \"sf\" \"data.frame\"` showing the area that can be reached from an origin point at a given travel time limit.\n\nobs. Most of these functions also allow users to account for monetary travel costs \nwhen generating travel time matrices and accessibility estimates. More info on\nhow to consider monetary costs can be found in [this vignette](https://ipeagit.github.io/r5r/articles/fare_structure.html).\n\n\nThe package also includes a few **support functions**.\n\n1. `street_network_to_sf()`\n   * Extract OpenStreetMap network in sf format from a `network.dat` file.\n\n2. `transit_network_to_sf()`\n   * Extract transit network in sf format from a `network.dat` file.\n\n3. `find_snap()`\n   * Find snapped locations of input points on street network.\n\n4. `r5r_sitrep()`\n   * Generate a situation report to help debug eventual errors.\n\n### Data requirements:\n\nTo use `r5r`, you will need:\n- A road network data set from OpenStreetMap in `.pbf` format (*mandatory*)\n- A public transport feed in `GTFS.zip` format (optional)\n- A raster file of Digital Elevation Model data in `.tif` format (optional)\n\nHere are a few places from where you can download these data sets:\n\n- OpenStreetMap\n  - [osmextract](https://docs.ropensci.org/osmextract/) R package\n  - [geofabrik](https://download.geofabrik.de/) website\n  - [hot export tool](https://export.hotosm.org/) website\n  - [BBBike.org](https://extract.bbbike.org/) website\n  - [Protomaps](https://protomaps.com/downloads/osm) website\n\n- GTFS\n  - [tidytransit](https://r-transit.github.io/tidytransit/) R package\n  - [transitland](https://www.transit.land/) website\n  - [Mobility Database](https://database.mobilitydata.org/) website\n  \n- Elevation\n  - [elevatr](https://github.com/jhollist/elevatr) R package\n  - [Nasa's SRTMGL1](https://lpdaac.usgs.gov/products/srtmgl1v003/) website\n\n\n\n### Demonstration on sample data\n\nSee a detailed demonstration of `r5r` in this [intro Vignette](https://ipeagit.github.io/r5r/articles/r5r.html). To illustrate\nfunctionality, the package includes a small sample data set of the public transport\nand Open Street Map networks of Porto Alegre (Brazil). Three steps are required to \nuse `r5r`, as follows.\n\n```R\n# allocate RAM memory to Java **before** loading the {r5r} library\noptions(java.parameters = \"-Xmx2G\")\n\nlibrary(r5r)\n\n# 1) build transport network, pointing to the path where OSM and GTFS data are stored\npath \u003c- system.file(\"extdata/poa\", package = \"r5r\")\nr5r_core \u003c- setup_r5(data_path = path, verbose = FALSE)\n\n# 2) load origin/destination points and set arguments\npoints \u003c- read.csv(system.file(\"extdata/poa/poa_hexgrid.csv\", package = \"r5r\"))\nmode \u003c- c(\"WALK\", \"TRANSIT\")\nmax_walk_time \u003c- 30   # minutes\nmax_trip_duration \u003c- 60 # minutes\ndeparture_datetime \u003c- as.POSIXct(\"13-05-2019 14:00:00\",\n                                 format = \"%d-%m-%Y %H:%M:%S\")\n\n# 3.1) calculate a travel time matrix\nttm \u003c- travel_time_matrix(r5r_core = r5r_core,\n                          origins = points,\n                          destinations = points,\n                          mode = mode,\n                          departure_datetime = departure_datetime,\n                          max_walk_time = max_walk_time,\n                          max_trip_duration = max_trip_duration)\n\n# 3.2) or get detailed info on multiple alternative routes\ndet \u003c- detailed_itineraries(r5r_core = r5r_core,\n                            origins = points[370, ],\n                            destinations = points[200, ],\n                            mode = mode,\n                            departure_datetime = departure_datetime,\n                            max_walk_time = max_walk_time,\n                            max_trip_duration = max_trip_duration,\n                            shortest_path = FALSE,\n                            drop_geometry = FALSE)\n\n# 4) Calculate number of schools accessible within 20 minutes \naccess \u003c- accessibility(r5r_core = r5r_core,\n                        origins = points,\n                        destinations = points,\n                        opportunities_colname = \"schools\",\n                        decay_function = \"step\",\n                        cutoffs = 21,\n                        mode =  c(\"WALK\", \"TRANSIT\"),\n                        verbose = FALSE)\n```\n\n#### **Related packages**\n\nThere is a growing number of `R` packages with functionalities for transport\nrouting, analysis and planning more broadly. Here are few of theses packages.\n\n- [dodgr](https://github.com/ATFutures/dodgr): Distances on Directed Graphs in R\n- [gtfsrouter](https://github.com/ATFutures/gtfs-router): R package for routing with GTFS data\n- [hereR](https://github.com/munterfinger/hereR): an R interface to the HERE REST APIs \n- [opentripplanner](https://github.com/ropensci/opentripplanner): OpenTripPlanner for R\n- [stplanr](https://github.com/ropensci/stplanr): sustainable transport planning with R\n\nThe **r5r** package is particularly focused on fast multimodal transport routing\nand accessibility. A key advantage of `r5r` is that is provides a simple and \nfriendly R interface to R\u003csup\u003e5\u003c/sup\u003e, one of the fastest and most robust routing\nengines available.\n\nFor ***Python*** users, you might want to check our sister package: [**r5py**](https://r5py.readthedocs.io/en/stable/)!\n\n-----\n\n# Acknowledgement\nThe [R\u003csup\u003e5\u003c/sup\u003e routing engine](https://github.com/conveyal/r5) is developed \nat [Conveyal](https://www.conveyal.com/) with contributions from several people.\n\n# Citation \u003cimg align=\"right\" src=\"r-package/man/figures/ipea_logo.png\" alt=\"ipea\" width=\"300\"\u003e\n\n The R package **r5r** is developed by a team at the Institute for Applied \n Economic Research (Ipea), Brazil. If you use this package in research \n publications, we please cite it as:\n\n* Pereira, R. H. M., Saraiva, M., Herszenhut, D., Braga, C. K. V., \u0026 Conway, M. W. (2021). **r5r: Rapid Realistic Routing on Multimodal Transport Networks with R5 in R**. *Findings*, 21262. [https://doi.org/10.32866/001c.21262](https://doi.org/10.32866/001c.21262)\n\nBibTeX:\n```\n@article{pereira_r5r_2021,\n\ttitle = {r5r: Rapid Realistic Routing on Multimodal Transport Networks with {R}$^{\\textrm{5}}$ in R},\n\tshorttitle = {r5r},\n\turl = {https://findingspress.org/article/21262-r5r-rapid-realistic-routing-on-multimodal-transport-networks-with-r-5-in-r},\n\tdoi = {10.32866/001c.21262},\n\tlanguage = {en},\n\turldate = {2021-03-04},\n\tjournal = {Findings},\n\tauthor = {Pereira, Rafael H. M. and Saraiva, Marcus and Herszenhut, Daniel and Braga, Carlos Kaue Vieira and Conway, Matthew Wigginton},\n\tmonth = mar,\n\tyear = {2021},\n\tnote = {Publisher: Network Design Lab}\n}\n```\n\nPlease also cite the relevant publications relating to the R⁵ engine on which *r5r* builds up:\n\n- Conway, M. W., Byrd, A., \u0026 van der Linden, M. (2017): **Evidence-Based Transit and Land Use Sketch Planning Using Interactive Accessibility Methods on Combined Schedule and Headway-Based Networks**. *Transportation Research Record*, 2653(1), 45–53. [DOI:10.3141/2653-06](https://doi.org/10.3141/2653-06)\n- Conway, M. W., Byrd, A., \u0026 Van Eggermond, M. (2018): **Accounting for uncertainty and variation in accessibility metrics for public transport sketch planning**. *Journal of Transport and Land Use*, 11(1). [DOI:10.5198/jtlu.2018.1074](https://doi.org/10.5198/jtlu.2018.1074)\n- Conway, M. W. \u0026 Stewart, A. F. (2019): **Getting Charlie off the MTA: a multiobjective optimization method to account for cost constraints in public transit accessibility metrics**. *International Journal of Geographical Information Science*, 33(9), 1759–1787. [DOI:10.1080/13658816.2019.1605075](https://doi.org/10.1080/13658816.2019.1605075)\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipeagit%2Fr5r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipeagit%2Fr5r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipeagit%2Fr5r/lists"}