• Stars
    star
    280
  • Rank 147,492 (Top 3 %)
  • Language Processing
  • License
    MIT License
  • Created over 7 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Animating scheduled transit trips using the Transitland API and Processing

Visualizing scheduled transit frequency

TransitFlow uses Mapzen's Transitland API to download transit schedule data and Processing with Unfolding Maps to animate scheduled transit frequency.

TransitFlow was created by Will Geary during an internship at Mapzen in 2017. See this blog post for more info: https://mapzen.com/blog/animating-transitland/

Here is an example animation generated for San Francisco with a single command:

python transitflow.py --name=san_francisco --bbox=-122.515411,37.710714,-122.349243,37.853983 --clip_to_bbox

IMAGE ALT TEXT

See here for more transit flow visualizations.

Install Processing

  1. Download Processing 3.
  2. Download Unfolding Maps version 0.9.9 for Processing 3.
  3. Navigate to ~/Documents/Processing/libraries on your machine.
  4. Drag and drop the unzipped Unfolding Maps folder into ~/Documents/Processing/libraries.
  5. Open Processing, navigate to Sketch > Import Library > Add Libary. Search for "Video Export" and click Install.
  6. Quit and re-open Processing.

Instructions

  • Download the repository, unzip it and cd into it
  • pip install -r requirements.txt to install the python requirements (pandas, numpy, requests)
  • cd transitflow

Now, you are ready to download transit schedule data and generate visualizations.

There are two ways to go about using this tool:

1) Search by transit operator Onestop ID

You can visualize a single transit operator by passing in the operator's Onestop ID. What's a Onestop ID, you ask? As part of Transitland's Onestop ID Scheme, every transit operator, route, feed and stop are assigned a unique identifier called a Onestop ID.

You can look up an operator's Onestop ID using the Transitland Feed Registery. For example, the Onestop ID for San Francisco BART is o-9q9-bart.

Visualize one day of BART transit flows:

  • python transitflow.py --name=bart --operator=o-9q9-bart

IMAGE ALT TEXT

2) Search by bounding box

You can also visualize transit flows by searching for all operators within a bounding box. The bounding box must be in the format: West, South, East, North. I like using bboxfinder to draw bounding boxes. For example, here's the command to visualize transit flows in Chicago:

  • python transitflow.py --name=chicago --bbox=-87.992249,41.605175,-87.302856,42.126747 --clip_to_bbox --exclude=o-9-amtrak,o-9-amtrakcharteredvehicle

IMAGE ALT TEXT

Note, the use of --clip_to_bbox. This command will clip the dataset to only include transit vehicle trips within the specified bounding box, both in the geo-visualization and in the vehicle count calculations that drive the stacked bar chart.

Also, note the optional use of --exclude. This command will exclude specified operators, Amtrak in this case.

Play your animation

Navigate to sketches\{name}\{date}\sketch and open the sketch.pde file.

This should open the Processing application. Simply click Play or command + r to play the animation.

Change map providers

Cycle through the first two rows on the keyboard (1 to 0, q to u) to see the built in map provider options.

Read more about Unfolding Maps map providers here: http://unfoldingmaps.org/tutorials/mapprovider-and-tiles.html

Panning and zooming

You can pan around on the map by clicking and dragging it. You can zoom in with Shift + "+" and zoom out with "-".

Exporting to video

Open sketch.pde file.

  • For a quick, medium quality video, set boolean recording = true;
  • For a high quality video, set boolean recording = true; and boolean HQ = true;. This will generate 3,600 .tiff frames that can be stiched together using ffmpeg or Processing's built in movie maker tool.

Command line arguments

Key Status Description Example
--name required The name of your project --name=boston
--date optional Defaults to today's date --date=2017-08-15
--operator optional Operator Onestop ID --operator=o-drt-mbta
--bbox optional West, South, East, North --bbox=-71.4811,42.1135,-70.6709,42.6157
--clip_to_bbox optional Clip results to bounding box --clip_to_bbox
--exclude optional Operators to be excluded --exclude=o-9-amtrak
--apikey optional Mapzen API key --apikey=mapzen-abc1234

A Mapzen API Key is optional, but recommended for faster results. Sign up for a Mapzen API Key here.

Troubleshooting

If your visualization is not working as expected...

  • Make sure that the operator of interest actually has service on the specified date (no --date argument defaults to today's date). Some operators are better than others at sharing updated data. For example, Mexico City's Metrobús has a service_end_date of 2016-08-17. So, you would need pass in a --date=2016-08-17 or earlier or to download and visualize the Metrobús.

  • Make sure that Transitland has coverage in your area of interest. You can search for transit operators and feeds using the Transitland Feed Registery. Is Transitland missing a feed? Let us know!

Attribution

Sources of inspiration

See more visualizations created with TransitFlow here: https://vimeopro.com/willgeary/transit-flows

Press & Recognition

More Repositories

1

transitland-atlas

an open directory of mobility feeds and operators — powers both Transitland v1 and v2
Python
124
star
2

transitland-datastore

Transitland v1 core components. Deprecated and only maintained occasionally. See Transitland v2.
Ruby
105
star
3

mapzen-geohash

Python package containing simple tools for encoding and decoding geohashes
Python
61
star
4

transitland

tracking issues about Transitland data or that cut across multiple codebases
49
star
5

mobility-explorer

Understand transportation networks around the world using Transitland open data and Valhalla routing engine APIs
JavaScript
38
star
6

mapzen-gtfs

Python library for reading and writing GTFS feeds
Python
30
star
7

gtfs-archives-not-hosted-elsewhere

A source for GTFS feed files available nowhere else. URLs are stable. To send in an updated archive or add a new feed, e-mail file to [email protected]
JavaScript
28
star
8

feed-registry

a directory of public-transit operators and their authoriative data feeds; a view into the Transitland v1 Datastore API
JavaScript
19
star
9

distributed-mobility-feed-registry

a JSON-based data schema to catalog mobility/transit/transportation data feeds
15
star
10

transitland-feed-registry

[DEPRECATED] a machine-readable registry of transit data feeds
Ruby
13
star
11

www-transit-land

static generator (running Jekyll) for Transitland v1 website
HTML
12
star
12

playground

[DEPRECATED] a friendly interface for the Transitland Datastore API, providing a way to view and download transit data without writing any lines of code
JavaScript
11
star
13

gtfs

Ruby library for dealing with GTFS. Used by Transitland's FeedEater import pipeline.
Ruby
8
star
14

transitland-python-client

Python
5
star
15

gtfs-data-exchange-archiver

Create an archive of historical GTFS Data Exchange feed versions and upload to Transitland
HTML
4
star
16

transitland-ruby-client

This Ruby library wraps the Transitland Datastore API, which allows querying of feeds, stops, routes, and other public-transit data from around the world
Ruby
4
star
17

dispatcher

DEPRECATED. Used to administer and monitor the Transitland Datastore back-end
JavaScript
3
star
18

station-hierarchy-exploratory-analysis

Exploring Station Hierarchies in Transitland
HTML
3
star
19

gtfs-agency-to-convex-hull

turn GTFS stops.txt into a bounding polygon and a geohash
JavaScript
3
star
20

ember-leaflet-draw

[DEPRECATED] wraps Leaflet.Draw in Ember Leaflet addon
JavaScript
2
star
21

transitland-valhalla-integration-testing-rig

Shell
1
star
22

ember-leaflet-polyline-decorator

Ember Leaflet Addon for L.PolylineDecorator
JavaScript
1
star
23

transitland-tiles-python

Transitland Tiles: Python client
Python
1
star
24

onestop-id-scheme

an attempt to link transit data across disparate sources
1
star