Re-projecting the geography of a city by travel time.
This works for any set of US counties, but it can be extended to use other shapes available from the US census.
How To Use
- You'll need these libraries if you don't already have them:
- numpy, pandas, and matplotlib
- Download the shapefiles from census.gov (I used the 500k ones). Unzip the contents into the same directory as this script. County shapefiles are HERE, but the analysis would work with any shapefiles, such as urban area, zip code, or even state or nation. Those can be found HERE.
- Get a Bing Maps API key by following these instructions.
- Look up the GEOID of areas you want to show from HERE. Enter them in as strings in the "settings" section of the code:
countyGEOIDs = ['29510','29189'] #st. louis city and county
How it Works
- Generate evenly-spaced coordinates within the boundaries of the outlines of the US counties you want.
- Connect to Bing Maps API and pull down travel distances between all the points.
- Use Multidimensional Scaling (aka Principal Coordinate Analysis) to turn the distance matrix into coordinates in time-space.
- Align the distance-space coordinates and the time-space coordinates using regular PCA
- Plot the coordinates using Matplotlib