4

Working on a SaaS application in PHP/Zend and want to provide users with the ability to search by neighborhood as well radius from zip code. We've been trying to find a decent Neighborhood DB of the US, but so far have only found very expensive sources.

Has anyone found/built a neighborhood db either by zip code or by lat/long?

4 Answers4

14

Just found a way to create my own Neighborhood database from 2 data sources. One is a complete file of US Zip codes with Lat/Long Centroids. The other is a free file from the USGS found at http://geonames.usgs.gov/domestic/download_data.htm

The good news is that the USGS file has a Feature Type called "Populated Places", which in urban areas contain neighborhood names. I tested against Urbanmapping and for San Francisco and Atlanta it had all but 1 of their neighborhood names (via Neighborhood API demo).

Since both the zip code file and the USGS file have lat/longs, the only thing left to do is to associate the neighborhood names with the zip codes. To do this you can use the following equation and compute the distance between all zip code lat/long and all Populated Place lat/long, then do a select based on the distance you want to include. I am using a 5 mile radius for the zip centroid. Here's the equation:

((ACOS(SIN(‘.$latitude.’ * PI() / 180) * SIN(latitude * PI() / 180) + COS(‘.$latitude.’ * PI() / 180) * COS(latitude * PI() / 180) * COS((‘.$longitude.’ – longitude) * PI() / 180))* 180 / PI()) * 60 * 1.1515) AS distance

Hope this helps other people struggling with the same issue and having a hard time justifying the cost of licensing this data (which is huge for a start up).

  • 3
    Richard, thanks for taking the time to post this! – runako Nov 09 '11 at 07:45
  • 1
    Can you post your code for this? – matthewlent Aug 06 '15 at 19:21
  • While this approach is on the right track, I highly recommend to avoid the `USGS "Populated Places"` dataset. It contains many unusual entries like "trailer parks", "mobile home parks", "campground", etc. Even worse, the neighborhood names are often not the familiar ones residents would know and use. The best approach is to download the large (free!) US dataset from `download.geonames.org` and parse that for certain "P" feature class entities. All the entries are pretty much good and familiar names. Then just do an exhaustive distance search to link each zipcode to nearest Geonames entry. – Special Sauce Nov 06 '15 at 14:57
  • It looks like the `Geonames.org` dataset also contains the mobile home and trailer park entries from the `USGS "Populated Places"` dataset, so you'll still need some string filtering. But the `Geonames.org` dataset definitely has noticeably better neighborhood names than the `USGS "Populated Places"` dataset. – Special Sauce Nov 06 '15 at 18:32
1

I think this covers your question: https://stackoverflow.com/questions/6095392/resolve-city-code-from-user-input/6354044#6354044

Alternatively this might offer value: resolve city from user input. In particular @Michael Borgwardt's answer.

Community
  • 1
  • 1
steenhulthin
  • 4,553
  • 5
  • 33
  • 52
0

not sure how good the data is, but Zillow has some creative commons data: http://www.zillow.com/howto/api/neighborhood-boundaries.htm

JeffCharter
  • 1,431
  • 17
  • 27
-1

I built this tool that would do the trick at least for the radius of the zip code:

http://www.woodstitch.com/resources/zip-code-catcher.php

If you need to know how to do get zip codes within an area pragmatically it get a bit more tricky but still very doable - I wrote blog explaining how to do it here: http://taylor.woodstitch.com/php/php-mysql-best-solutions-for-finding-points-in-a-polygon-from-a-database/

underdog
  • 17
  • 2