Wednesday, August 28, 2013

City boundaries with Google Maps and OpenStreetMap

As per my post about comparing city boundaries (limits), this post will explain some of the technical details behind getting and drawing city boundaries.

Firstly, I have written an example web app to illustrate drawing city boundaries on Google Maps with OpenStreetMap here:


This does much of the same thing as the web app I published last week, but with a lot stripped out to make it easier to understand. The GitHub page also has more of the technical detail laid out.

When I initially started this project I looked into various sources for this information. The Google Maps API v3 itself does not provide it, and many people recommend Twitter. This would have been great but it looks like Twitter changed the API for this particular call to require user authentication and limit use to only 15 calls per user per 15 minute window. So I ended up implementing this with OpenStreetMap using the Overpass API.

The main two issues with this:

  • Creating OpenStreetMap queries to find the data which is labelled inconsistently. 
  • The data not existing for some cities at all, including major cities like Dallas and Los Angeles.
If you need great data without major holes like this I recommend against using OpenStreetMap data. The first issue I have attempted to mitigate with the queries I have set up (see the GitHub page above), but more work will have to be done here to make it perfect.

Here is the Twitter API call I mentioned:


  1. can you give me an example with Twitter API version?

    1. I haven't done this myself but I would start by looking at the Twitter API here:

      There are a couple of good SO answers on the topic as well. Here is one: