Forum OpenACS Q&A: zip code proximity search
I wanna offer a zip code proximity search on my website. Very like what is done at Greenpeace Nuclear Reactor Locator. Can anyone with experience in this give me some tips or even (gasp and quiver) some code to get me started?
Since the tiger files are imported (with some errors I might add), basically you have the zip code and the lat/long of the center point of the zip code.
From that, with a little vector math, you can take the lat/long of your subsets, and come up with a vector which can then be converted to miles or some other scalar.
Since the US is pretty small compared to the world, you could probably use some average to fix the difference in lat/long distances as you get closer to the pole. The closer to the pole, the shorter the distance between each degree of longitude.
I don't think you could say with any great certainty the exact distance, but, you could do the vector math and determine the listings in ascending scalar length.
-- or so the theory goes.
Another way to cheat would be to take the original zip code, get the FIPS county code, and then pull any listing with a similar FIPS county code making the assumption that people won't generally go out of their county to find whatever service. Much simpler to implement -- but people living near Washington DC can easily drive 20 minutes and reach 5 counties, 2 states and the district.
I haven't had the time to write an api to use the reference data, and haven't seen anything that does this already. If I finish before you, I'll publish the api.
The data that is used for the Tiger files is actually a one-off project that the Census Bureau did and if I recall, is not something they have supported since 1999.
See the notes in the package.
Thanks for all the info everyone. I emailed Brad on his honeymoon, as CR suggested, to see if what they have will work for me. That would be the best news as this seems not a trivial task.
I just ran across zipdy and wonder if that is a possibility. It is GPL'd and works on postgresql in PHP, Perl or C. Might be a good backup to look at.
How much does the 2002 census data cost?
I just need Brad to get back home:)
thanks so much:)
When I compared the 1999 with the 2000 data, IIRC, I found pretty much no new zipcodes, but many new town names.
Recently I've been doing quite a bit of cross country driving and it has taken me into towns that don't exist according to the 2000 data. The zip codes exist. The zip codes for the most part are in the same place. It's the name of the town that doesn't exist. New developments like Cuesta Verde....
And to get ecommercy, which towns are likely to hold the yuppies using your service? The new towns. For the most part a zip-code lookup will work, but there's a reasonable chance a townname lookup will fail.
If you visit the USPS, you will find that the towns do exist as well, but it's in their please don't crawl me database.
From what I recall of the zipdy package it appears there are about 40,000 zip codes, not really all that many. And not that many town names either. It's a crime that the information is available online, that's it a small dataset but that they don't allow spidering it. I once estimated less than a floppy compressed for the full dataset and just a few Kbytes to publish just diffs.
To put on a political hat, this is something a reinventing gov't administration should have released to the people (and I guess they did) and something a small business is number one kind of administration should be releasing to the people.
Very seriously, if anyone knows of a pro-bono lawyer that might be interested in this sort of thing, I would love to speak with him or her.
which allows you to do just about anything mail related you could want to. I think USPS would argue that it's not their business to provide geocoding databases - they are charged with delivering mail. That's why the previous dataset was actually from census (as is the one used for the google contest).
I've seen several posts recently about people wanting web services - maybe we as a community should tackle coding for this, Bundespost and a few others ...
This used to be in new-file-storage. If anyone wants it, or if it's wanted in contrib in cvs then lemme know.