#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:
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:
- Getting places is slower as you approach the city (the right side of the map)
- There are some places deep in the county (bottom left) that are remote
You can see the points clump together in lines. These are highways — it’s easier to get between two points on the same highway.
We could, of course, make the same map by walking travel-time, rather than driving. The results should not surprise you:
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.
How It Works
- I download shapefiles from the census to draw the boundaries of the areas.
- The script calculates evenly spaced points (latitude/longitude) within the boundary.
- 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.
- It uses multidimensional scaling (aka Principal Coordinates Analysis) to arrange the points in “Time-Space”.
- It attempts to align the “distance-space” coordinates with the “time-space” coordinates using regular Principal Component Analysis.
- It uses Matplotlib to plot the results.
Future Improvements
- More points. Right now that’s limited by the size of the query to Bing Maps API, but it can be fixed by making multiple queries.
- Better visualization. I threw this together quickly in Matplotlib, but I think the data can be presented better.
- Public transportation. Currently Bing Maps API doesn’t handle this well.
- Travel-time at certain hours. As you can imagine, the map would look very different during rush hour. Currently, Bing Maps API isn’t very good at giving you data during alternate hours, but one can imagine a GIF which shows how the suburbs get “farther away” in time-space during a heavy commute.
Thanks for reading! If you have any questions, hit me up at (this website name)@gmail.com