[thelist] searching using postal codes in the USA

sbeam sbeam at syxyz.net
Thu Aug 19 07:27:43 CDT 2004


On Thursday 19 August 2004 07:00 am, Bird wrote:
> "How does a website provide search information in the USA using
> postal code and within certain miles of where a person doing the
> search is living ?"

You need a database of all the zip codes in the USA with a corresponding 
Lat/Long value for each one. To calculate the distance between two 
zipcodes, you use a standard formula for calculating distance over the 
surface of a sphere. This can be googled up easily. Thats pretty much 
it. You can also get a database of all cities/town in the US with zip 
codes so you can do it by locality name rather than zip.

To get a set of points within a certain radius of a given zipcode (I 
think this is what you are asking, like a store locator) its just more 
labor on the part of your script, you have to do the calculation for 
every point and see if the result < x. You could narrow it down first 
by selecting points within min/max lats and longs (defining a 
"square"... but 1 degree of latitude = 0 miles at the poles and ~22 
miles at the equator, so you have to be careful...)

You can get the databases from various commercial vendors (ours was $150 
IIRC), and I think the US Census Bureau has a free one but its totally 
inscrutable and not up to date. 
http://www.zipinfo.com/products/products.htm

here is article that goes into more detail:
http://www.dbazine.com/weeg9.html

-- 

# S Beam - Web App Dev Servs
# http://www.onsetcorps.net/


More information about the thelist mailing list