Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/UrbanAnalyst/gtfsrouter
Routing and analysis engine for GTFS (General Transit Feed Specification) data
https://github.com/UrbanAnalyst/gtfsrouter
gtfs gtfsrouter public-transportation r-package router
Last synced: about 1 month ago
JSON representation
Routing and analysis engine for GTFS (General Transit Feed Specification) data
- Host: GitHub
- URL: https://github.com/UrbanAnalyst/gtfsrouter
- Owner: UrbanAnalyst
- Created: 2019-01-28T08:28:13.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T09:01:44.000Z (about 2 months ago)
- Last Synced: 2024-10-29T10:03:57.338Z (about 2 months ago)
- Topics: gtfs, gtfsrouter, public-transportation, r-package, router
- Language: R
- Homepage: https://urbananalyst.github.io/gtfsrouter/
- Size: 11.1 MB
- Stars: 82
- Watchers: 10
- Forks: 17
- Open Issues: 13
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: CONTRIBUTING.md
- Codemeta: codemeta.json
Awesome Lists containing this project
- open-sustainable-technology - gtfs-router - An R package for routing with GTFS (General Transit Feed Specification) data. (Consumption / Mobility and Transportation)
README
[![R build
status](https://github.com/UrbanAnalyst/gtfsrouter/workflows/R-CMD-check/badge.svg)](https://github.com/UrbanAnalyst/gtfsrouter/actions?query=workflow%3AR-CMD-check)
[![codecov](https://codecov.io/gh/UrbanAnalyst/gtfsrouter/branch/main/graph/badge.svg)](https://app.codecov.io/gh/UrbanAnalyst/gtfsrouter)
[![Project Status: Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/gtfsrouter)](https://cran.r-project.org/package=gtfsrouter)
[![CRAN Downloads](http://cranlogs.r-pkg.org/badges/grand-total/gtfsrouter?color=orange)](https://cran.r-project.org/package=gtfsrouter)**R** package for public transport routing with [GTFS (General Transit Feed
Specification)](https://developers.google.com/transit/gtfs/) data.## Installation
You can install latest stable version of `gtfsrouter` from CRAN with:
```{r cran-installation, eval = FALSE}
install.packages ("gtfsrouter")
```Alternatively, the current development version can be installed using any of
the following options:```{r gh-installation, eval = FALSE}
# install.packages("remotes")
remotes::install_git ("https://git.sr.ht/~mpadge/gtfsrouter")
remotes::install_git ("https://codeberg.org/UrbanAnalyst/gtfsrouter")
remotes::install_bitbucket ("urbananalyst/gtfsrouter")
remotes::install_gitlab ("UrbanAnalyst/gtfsrouter")
remotes::install_github ("UrbanAnalyst/gtfsrouter")
```To load the package and check the version:
```{r pkg-version, eval=TRUE}
library (gtfsrouter)
packageVersion ("gtfsrouter")
```## Main functions
The main functions can be demonstrated with sample data included with the
package from Berlin (the "Verkehrverbund Berlin Brandenburg", or VBB). GTFS
data are always stored as `.zip` files, and these sample data can be written to
the temporary directory (`tempdir()`) of the current R session with the
function `berlin_gtfs_to_zip()`.```{r create-zip, eval = TRUE}
filename <- berlin_gtfs_to_zip ()
print (filename)
```For normal package use, `filename` will specify the name of a local GTFS `.zip`
file.### gtfs_route
Given the name of a GTFS `.zip` file, `filename`, routing is as simple as the
following code:```{r example-echo, echo = TRUE, eval = FALSE}
gtfs <- extract_gtfs (filename)
gtfs <- gtfs_timetable (gtfs, day = "Wed") # A pre-processing step to speed up queries
gtfs_route (gtfs,
from = "Tegel",
to = "Berlin Hauptbahnhof",
start_time = 12 * 3600 + 120
) # 12:02 in seconds
```
```{r example, echo = FALSE, message = FALSE}
gtfs <- extract_gtfs (filename)
gtfs <- gtfs_timetable (gtfs)
r <- gtfs_route (gtfs,
from = "Schonlein",
to = "Berlin Hauptbahnhof",
start_time = 12 * 3600 + 120
) # 12:02 in seconds
knitr::kable (r)
```### gtfs_traveltimes
The [`gtfs_traveltimes()`
function`](https://UrbanAnalyst.github.io/gtfsrouter/reference/gtfs_traveltimes.html)
calculates minimal travel times from any nominated stop to all other stops
within a feed. It requires the two parameters of start station, and a vector of
two values specifying earliest and latest desired start times. The following
code returns the fastest travel times to all stations within the feed for
services which leave the nominated station ("Alexanderplatz") between 12:00 and
13:00 on a Monday:```{r isochrone, eval = TRUE, message = FALSE}
gtfs <- extract_gtfs (filename)
gtfs <- gtfs_timetable (gtfs, day = "Monday")
x <- gtfs_traveltimes (gtfs,
from = "Alexanderplatz",
start_time_limits = c (12, 13) * 3600
)
```The function returns a simple table detailing all stations reachable with
services departing from the nominated station and start times:```{r iso-results1-fakey, eval = FALSE}
head (x)
```
```{r iso-results1, eval = TRUE, echo = FALSE}
knitr::kable (head (x))
```Further details are provided in a [separate
vignette](https://UrbanAnalyst.github.io/gtfsrouter/articles/traveltimes.html).### gtfs_transfer_table
Feeds should include a "transfers.txt" table detailing all possible transfers
between nearby stations, yet many feeds omit these tables, rendering them
unusable for routing because transfers between services can not be calculated.
The `gtfsrouter` package also includes a function,
[`gtfs_transfer_table()`](https://UrbanAnalyst.github.io/gtfsrouter/reference/gtfs_transfer_table.html),
which can calculate a transfer table for a given feed, with transfer times
calculated either using straight-line distances (the default), or using more
realistic pedestrian times routed through the underlying street network.This function can also be used to enable routing through multiple adjacent or
overlapping GTFS feeds. The feeds need simply be merged through binding the
rows of all tables, and the resultant aggregate feed submitted to the
[`gtfs_transfer_table()`](https://UrbanAnalyst.github.io/gtfsrouter/reference/gtfs_transfer_table.html)
function. This transfer table will retain all transfers specified in the
original feeds, yet be augmented by all possible transfers between the multiple
systems up to a user-specified maximal distance. Further details of this
function are also provided in another [separate
vignette](https://UrbanAnalyst.github.io/gtfsrouter/articles/transfers.html).## Additional Functionality
There are many ways to construct GTFS feeds. For background information, see
[`gtfs.org`](https://gtfs.org), and particularly their [GTFS
Examples](https://docs.google.com/document/d/16inL5BVcM1aU-_DcFJay_tC6Ni0wPa0nvQEstueG5k4/edit).
Feeds may include a "frequencies.txt" table which defines "service periods",
and overrides any schedule information during the specified times. The
`gtfsrouter` package includes a function,
[`frequencies_to_stop_times()`](https://UrbanAnalyst.github.io/gtfsrouter/reference/frequencies_to_stop_times.html),
to convert "frequencies.txt" tables to equivalent "stop_times.txt" entries, to
enable the feed to be used for routing.## Contributors
All contributions to this project are gratefully acknowledged using the [`allcontributors` package](https://github.com/ropensci/allcontributors) following the [all-contributors](https://allcontributors.org) specification. Contributions of any kind are welcome!
### Code
### Issue Authors
### Issue Contributors