Is your city breathing or hyperventilating?
Cartograms are maps that distort geographical shapes to convey their attributes. While less suitable for serious analysis than choropleths, they can be more visually engaging. In this mini-project, I used cartograms to visualize green and yellow cab ridership in New York City in April, 2019.
Method
- Combine green and yellow cab trips into a single pandas dataframe.
- Sum passenger pick-ups and drop-offs by zone, time (to the nearest half hour), and day type (weekend or weekday).
- Calculate the cumulative sums for both pick-ups and drop-offs for each zone.
- Adjust zone area according to the expression: 1 + (cumul. drop-offs - cumul. pick-ups) / cumul. pick-ups
- Adjust zone color according to number of drop-offs at a given point in time.
Originally inspired by Yan Holtz’s work in R, this project uses Matthieu Viry’s cartogram_geopandas package and Paco Nathan’s approach to creating gif animations. To retrieve the taxi trip data, I also borrowed code from Chih-Ling Hsu’s blog post.
Results
As expected, the animations show that most drop-offs occur in mid-town Manhattan. Surprising, though, is that trip volumes are asymmetrical. There are more taxi trips going into the CBD than those leaving, which suggests that many commuters take a cab to work but then take transit back home.
I plan to recreate the animation when New York City releases data from 2020 in order to show how lock-down orders have affected taxi ridership.
Check out my Jupyter Notebook here.