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:

city-boundaries-google-maps

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:

Line Segment Intersection

I wrote a small JavaScript function to test whether two lines segments intersect. It uses the vector cross product approach described here: http://stackoverflow.com/a/565282/786339.

The code is available here: line-segments-intersect

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


Sunday, August 4, 2013

Comparing Two Cities

Compare Two Cities

I like comparing city populations and sizes to see how they stack up against each other. You have to look beyond just the population to really gauge the size and how they compare. So I made a little web app to do it! It's written in JavaScript and currently only supports cities with a population of at least 50,000. Enter a city in the format "New York, NY" and Give it a try!

Enter two cities to compare:

1) I would like to transition the app to use the census API found here: http://www.census.gov/developers/

2) Eventually I would like to compare cities by taking the actual land area of one city and expanding/shrinking the city limits to the land area of a different city and measuring the population from those new city limits.

Some hurdles would potentially be: Expanding a city in an intelligent way so as to avoid uninhabitable area, getting the population of an area defined by a polygon and maybe getting the population to enough detail.

After some research I believe this may be theoretically possible by expanding/shrinking the city limits in the direction of population centers of the surrounding area. For example, if you looked at a choropleth map of population density you would easily be able to tell in what direction it logically made sense to expand or shrink a city while avoiding uninhabited areas. It also appears that census data is accurate down to the block, which should certainly be sufficient for these purposes.

Wednesday, July 17, 2013

RNA Secondary Structure Prediction

Here is the poster I put together covering the work I did during an REU (Research Experience for Undergraduates) in applied intelligent systems in the summer of 2010. It covers RNA secondary structure prediction using a new method of heuristic backtracking. The heuristic took into account the biology of RNA folding.


Thursday, February 14, 2013

yourShuffle Update

The first update to yourShuffle was just approved and is available for download. Fixes bugs introduced with iOS 6.1.

Friday, February 8, 2013

yourShuffle Week 1 Downloads

Here are the week one downloads for my yourShuffle app that I released last Friday. Overall 148 downloads! I am pretty happy with that number and very surprised by all the different countries.

My ranking in the search results for the "music shuffle" search term dropped dramatically yesterday and I have no idea why. My downloads have also gone down as a result. After some research there doesn't seem to be much you can do about it, but I did submit better keywords with the my latest update so hopefully that helps a bit. 

The first update will hopefully be out this week sometime and has some major bug fixes particularly for iOS 6.1 on the iPhone 4 and 4S.

All in all a great first week!


United States
65

France
11

Japan
8

Canada
5

China
5

United Kingdom
5

Australia
4

Germany
4

Netherlands
3

Thailand
3

New Zealand
3

Mexico
3

Taiwan
3

Brazil
2

Ireland
2

Norway
2

Turkey
2

Sweden
2

India
2

Cambodia
1

Uzbekistan
1

Saudi Arabia
1

Chile
1

Spain
1

Denmark
1

Philippines
1

Finland
1

Russia
1

Egypt
1

South Africa
1

Azerbaijan
1

Malaysia
1

Austria
1