Saturday, August 17, 2013

Comparing City Limits

Compare City Sizes

More comparing city awesomeness! This uses the OpenStreetMap Overpass API to retrieve city boundaries and then draw them as polygons using the Google Maps API. It then moves the first city to the location of the second and overlays them to allow for easy visual comparison.

The OpenStreetMap Overpass API
The Google Maps API

I will be posting the core code here on GitHub once I get a chance to fix it up and utilitize it a bit better. It does look like there are people trying to do similar stuff. I will also walk through how I interpreted the OpenStreetMap boundaries to get a polygon because it was fairly unintuitive.

Of note is that due to inconsistently labelled data some cities will not return boundaries from OpenStreetMap. I may investigate making the search more robust. For others cities the boundaries do not exist in OpenStreetMap at all (i.e. Dallas and LA). Another issue is my census data seems to think that the lat and lon for San Francisco are the Farallon islands (they are technically part of SF). So it centers maps there when comparing cities to San Francisco, I have not seen this elsewhere.

It also looks like I have to fix up how this displays on blogger as it seems to be displaying a few elements of map incorrectly. Same constraints as the previous post, only cities of 50,000 and enter as "City Name, State Name".

Compare to Ajax Loading


1 comment: