Coder Social home page Coder Social logo

hansmib / gtfs-router Goto Github PK

View Code? Open in Web Editor NEW

This project forked from urbananalyst/gtfsrouter

0.0 1.0 0.0 1.96 MB

Routing and analysis engine for GTFS (General Transit Feed Specification) data

Home Page: https://atfutures.github.io/gtfs-router/

R 64.74% Makefile 0.33% C++ 34.94%

gtfs-router's Introduction

Build Status AppVeyor Build Status codecov Project Status: Active CRAN_Status_Badge CRAN Downloads

GTFS Router

R package for routing with GTFS (General Transit Feed Specification) data. See the website for full details.

Installation

To install:

remotes::install_github("atfutures/gtfs-router")

To load the package and check the version:

library(gtfsrouter)
packageVersion("gtfsrouter")
## [1] '0.0.1'

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 local storage with the function berlin_gtfs_to_zip().

berlin_gtfs_to_zip()
tempfiles <- list.files (tempdir (), full.names = TRUE)
filename <- tempfiles [grep ("vbb.zip", tempfiles)]
filename
## [1] "/tmp/Rtmpz6vX0h/vbb.zip"

For normal package use, filename will specify the name of the local GTFS data stored as a single .zip file.

gtfs_route

Given the name of a GTFS .zip file, filename, routing is as simple as the following code:

gtfs <- extract_gtfs (filename)
gtfs <- gtfs_timetable (gtfs) # A pre-processing step to speed up queries
gtfs_route (gtfs,
            from = "Schonlein",
            to = "Berlin Hauptbahnhof",
            start_time = 12 * 3600 + 120) # 12:02 in seconds
route_name trip_name stop_name arrival_time departure_time
U8 U Paracelsus-Bad U Schonleinstr. (Berlin) 12:04:00 12:04:00
U8 U Paracelsus-Bad U Kottbusser Tor (Berlin) 12:06:00 12:06:00
U8 U Paracelsus-Bad U Moritzplatz (Berlin) 12:08:00 12:08:00
U8 U Paracelsus-Bad U Heinrich-Heine-Str. (Berlin) 12:09:30 12:09:30
U8 U Paracelsus-Bad S+U Jannowitzbrucke (Berlin) 12:10:30 12:10:30
S5 S Westkreuz S+U Jannowitzbrucke (Berlin) 12:15:24 12:15:54
S5 S Westkreuz S+U Alexanderplatz Bhf (Berlin) 12:17:24 12:18:12
S5 S Westkreuz S Hackescher Markt (Berlin) 12:19:24 12:19:54
S5 S Westkreuz S+U Friedrichstr. Bhf (Berlin) 12:21:24 12:22:12
S5 S Westkreuz S+U Berlin Hauptbahnhof 12:24:06 12:24:42

gtfs_isochrone

Isochrones from a nominated station - lines delineating the range reachable within a given time - can be extracted with the gtfs_isochrone() function, which returns a list of all stations reachable within the specified time period from the nominated station.

gtfs <- extract_gtfs (filename)
gtfs <- gtfs_timetable (gtfs) # A pre-processing step to speed up queries
x <- gtfs_isochrone (gtfs,
                     from = "Schonlein",
                     start_time = 12 * 3600 + 120,
                     end_time = 12 * 3600 + 720) # 10 minutes later

The function returns an object of class gtfs_isochrone containing sf-formatted sets of start and end points, along with all intermediate (“mid”) points, and routes. An additional item contains the non-convex (alpha) hull enclosing the routed points. This requires the packages geodist, sf, alphahull, and mapview to be installed. Isochrone objects have their own plot method:

plot (x)

The isochrone hull also quantifies its total area and width-to-length ratio.

GTFS Structure

For background information, see gtfs.org, and particularly their GTFS Examples. The VBB is strictly schedule-only, so has no "frequencies.txt" file (this file defines “service periods”, and overrides any schedule information during the specified times).

gtfs-router's People

Contributors

mpadge avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.