#geography #python

Making Maps in 'Time-Space' with Python

Published Dec 2, 2018 by Alik Ulmasov


You can find the code for this on my Github. I walk through it there.

How can we make maps by travel-time, rather than distance?

This project was inspired by this analysis from Gradient Metrics in which they re-projected Manhattan Island into “Timespace”, which shows how long it takes to get from any two points (via public transportation, in their case).

Unfortunately, they didn’t share their code. I’ve tried to do the same analysis in Python, and generalize it so it works with any place (e.g. city, county, state, etc). For example, here is St. Louis City and County:

STL City and County

On the left is the St. Louis area in “distance space“, where the dots are all equally spaced on a map. On the right are the same dots in “time space“, where the distances between the points represent driving time, instead of geographic distance.

The take-aways from this map are not super obvious, but we can begin to see a few things:

We could, of course, make the same map by walking travel-time, rather than driving. The results should not surprise you:

STL City and County (Walking)

Yep — it takes about the same amount of time to walk between equally spaced points. This shows that takes roughly 600 minutes (10 hours) to walk across the entire St. Louis area.

Finally, here’s an example of another city, Washington DC. This is at 8pm on a Saturday, but you can imagine it would look very different during rush hour.

DC in Time-Space

How It Works

  1. I download shapefiles from the census to draw the boundaries of the areas.
  2. The script calculates evenly spaced points (latitude/longitude) within the boundary.
  3. It uses the Bing Maps API to pull down all of the driving times between all of the points. Then it turns them into a distance matrix. I would of used Google Maps, but I’m not sure it’s possible anymore.
  4. It uses multidimensional scaling (aka Principal Coordinates Analysis) to arrange the points in “Time-Space”.
  5. It attempts to align the “distance-space” coordinates with the “time-space” coordinates using regular Principal Component Analysis.
  6. It uses Matplotlib to plot the results.

Future Improvements

Thanks for reading! If you have any questions, hit me up at (this website name)@gmail.com



*****

© 2021 Alik Ulmasov