NYC scaled to commute time, part 2

What would New York City look like if the distance between places was actually the time it takes to get between them in rush hour?

by Zachary Nichols

This is part 2 of the post on rescaling NYC based on transit time. Part 1 is here.

Last time, I showed some maps of New York where I replaced normal distance with the time it takes to get between places on MTA. Here’s a video of the transformation from normal to time-scaled and back again:

I also mentioned last time that I would take a shot at doing a Manhattan-only version. Just as a note, this won’t look just like a bigger version of the deflated Manhattan balloon in the full map. That’s because the scaling algorithm I used (multi-dimensional scaling) is trying to take all the distances into account that it sees in order to put them into a 2D map that makes sense. Of course, the distances I give it don’t really fit into a 2D world, and the projection chosen can be very different when I use only part of the map.

Here’s (boring old) Manhattan:

manhattan_med

And here’s Manhattan rescaled for MTA travel time. It’s not as interesting as the full map, but we can see some of the obvious features: getting across town above 60th St. or so is a huge pain, and getting acrosstown in general is a slower prospect than going North/South.

scaled_manhattan

It is a little bit notable that the Manhattan-only version is not as dramatically scaled as Manhattan is in the full map. It suggests maybe the reason Manhattan was as squished as it was is that the transit time in the outer boroughs is comparatively much longer.

Anyway, in case anyone is interested, here is the nitty gritty behind how I made these maps. First, to calculate the MDS rescaling, the first thing I need is a set of points and the distances between them.

To get these points efficiently, I used a bit of a shortcut. I made a hexagonal lattice covering NYC (including some of Long Island, New Jersey, Westchester, and a lot of water). To find out which lattice points were actually in the city, used google’s maps api to probe the geographic information of the point. After eliminating everything not actually in the city, I was left with these 800 or so points (colored by neighborhood):

v2

The next step of course was to find the time it takes to get between them via MTA. Ideally, I would just use google maps’ distance matrix to get the whole calculation at once. Alas, the rights restrictions on public transit data prohibits google from allowing them to give distance matrix calculations on transit times (they do allow such calculations for roads etc.).

At this point I had a bit of a decision to make. I could be a total jerk and try to get the travel times between all the points from google maps anyway with a screen scraper or something like that, but it turns out there’s a much better solution. Since MTA is kind enough to publish their transit data, I had the opportunity to (with a little bit of work) use Open Trip Planner to set up a local server that allows me to get the transit times via a REST api. So I could still spam and spam to get travel times, but it would be on my local machine rather than someone else’s server.

After filling in a matrix with travel times, I was forced to fire up Matlab (which has a very easy-to-useimplementation of multi-dimensional scaling). Getting the results of this rescaling (and matching them up to the original latitude / longitude with a call to procrustes), I get a point-wise remapping of the lattice.

vectors

Here is the original lattice with arrows pointing to where the rescaling puts them.

Finally, I used Quantum GIS to make some annotated maps of NYC, and skewed them in Python according to the remapping. Since not every point in the map was in the lattice, I used a weighted average to interpolate between the lattice points, and allow me to make the final maps.

Of course, this is meant only as an interesting exercise, but these types of maps do have applications. A lot of what real GIS people do is planning — planning new roads, planning where to put hospitals and fire stations, etc. Knowing how long it takes to get between places can be very critical when placing a fire station for example: you really want to minimize response and travel time for as many places as you can. Having this type of map can help with visualizing where you should position your emergency services to get even coverage, the same way a map like this might help a New Yorker decide where to look for an apartment that’s convenient for work and play.