Citibike Availability Visualized with Clojure/Quil
New York City recently launched a public bike share scheme very much in the spirit of similar systems around the world. As an avid cyclist and fan of public transportation, I've been eager to see how the program would do. Luckily, they've got an API that delivers on-demand station status, so I set up a cron job to collect system-wide information every 15 minutes and built a visualization.
This video shows the first five business days during which the Citibike service was available to the public. Every second of the video depicts roughly one hour of real time. Pale blue circles represent stations, with the circle's size scaled to the capacity of that station. Dark blue circles represent how many bikes are available at that station.
There are 307 active stations reporting a total parking capacity of 10,680 slots. The data feed doesn't give per bike information, so I was forced to estimate the number of bicycles in the system using the greatest number parked at one time: 4,744. My data collection script only ran every 15 minutes, but it managed to detect 32,947 trips over the five days, with an estimated high of 844 bikes on the road at once. The official Citibikes blog says there were 61,267 trips, which I can only assume means that there are many short trips that happen in between my sampling window.
Monday was the first day on which the program was open to the public. While there was considerable use of Citibikes that day, it was substantially less than on subsequent days.
Commuters took to the system in earnest on Tuesday. Bicycles gathered in various business districts -- Midtown, Downtown Brooklyn and Wall Street -- between eight and nine in the morning, then dispersed to more residential neighborhoods, like the Lower East Side and Williamsburg, between five and seven in the evening. The same pattern persists Wednesday and Thursday, but on Friday the bikes are nearly static, presumably because it rained hard all day.
The busiest stations were all in Manhattan, and were all close to major transportation hubs:
- Broadway and W 57 Street (Columbus Circle)
- 8 Avenue and W 31 Street (Penn Station)
- W 41 Street and 8 Avenue (Port Authority)
- W 33 Street and 7 Avenue (Penn Station, again)
- Broadway and E 14 Street (Union Square)
I find it interesting to compare this with Alastair Coote's projection of which neighborhoods would most benefit from Citibikes.
One obvious pair of tools for this sort of visualization is Processing and Till Nagel's tile map library, Unfolding. Processing is great, and its library ecosystem is immense, but I find the Processing language frustrating for anything other than specifying the details of a sketch. This led me to a Clojure wrapper for Processing called Quil. Quil allows one to take advantage of Processing and related libraries in the context of a much more expressive language. In addition, operating Quil from emacs via nrepl makes it possible to modify the "draw loop" of a sketch from the editor while the sketch is running, which massively reduces development time.
When I looked into how one might go about using a supplemental Processing library in Quil, all I found was this question in a Google Group, so I thought it might be worth documenting the process here.
$ lein localrepo install lib/Unfolding.jar unfolding 0.9.3
After which one can add Unfolding to one's project.clj dependencies as if it were in Clojars:
The complete source code and data for this visualization can be found at GitHub.