I am looking for a zipcode locator function. I want to be able to search my database of locations between x mile radius of xxxxx zipcode. Does anyone know where i can find this?
Thanks
Neil
| SitePoint Sponsor |
I am looking for a zipcode locator function. I want to be able to search my database of locations between x mile radius of xxxxx zipcode. Does anyone know where i can find this?
Thanks
Neil
Keep It Real





Something like this? http://zipfindlocator.com/default.htm
been there, seen that, im looking for a free result. Or a free database. I have done some research and im sure i will be able to calculate the distances if i had the latitude and longitude of zipcodes. Simple Trig
Neil
Keep It Real





"simple" trig LOL
I will keep a look out for a free zip code database





This is want you want to build?
1. User enters zip code
2. Your database returns the position (x,y) of that zip code (in the middle of that area, I guess)
3. Add R miles to that position
4. Get all other zip codes with position within the radius R from (x,y)
(5. Get some other interesting information, e.g. companies having those zip codes)
I don't think you will find a free database
If you visit US Postal Services, you will find "The information you are seeking is not available via download but is provided through the National Customer Support Center at (800) 238-3150"
Other countries may give away the zip code info for free, for example the Faroe Islands
Reflection:
I think you should convert the Latitude/Longitude to a position in the US National Grid System, because the distance between two longitudes isn't the same on all latitudes
How to read USNG
National Geodetic Survey





And the distance between two latitudes isn't always the same ...
http://www.rovaniemi.fi/lapinkavijat...index_eng.html
"His aim was by measuring a degree of latitude along a line of longitude to investigate whether the earth was flattened at its poles."
And yes, of course I have been to the monument on the top of the Kittisvaara fell in Pello![]()
Not only that but Zip Codes in the United States are not setup for a set area. They are based on Population density. Not only that where I live, we have one main post office which handles 4 different zip codes. One of those zipcodes is limited to post office boxes within the building.
To do what you want to do is a lot more than simple trig.
The Melissa software can do that (I believe) but it's certainly not free.
Owen
Yes i know, it doesn't have to be exact.
Thanks for all your help
Neil Conlan
Keep It Real





Yes, that was my reflection number two that I forgot in my previous answer; zip codes are related to areas of different size, and somewhere (Alaska?) there must be a zip code very difficult to associate with a specific positionOriginally posted by W. Luke
Not only that but Zip Codes in the United States are not setup for a set area. They are based on Population density. ...
Isn't a map where the user can select a city a better idea? (And latitude & longitude for a city is easier to find)



I think I may have what you need... Im working on finishing a similar database. What exactly do you need? I want to give back to this community who has been very helpful to me in the past.
What you are looking for can be found here. Data is from 1990 Census (that's what you get when the price is $0):
http://spatialnews.geocomm.com/newsl.../zipcodes.html
Scroll down to US Census. It's a zip file containing a comma separated values file (saved oddly as .txt). You'll need to import it into your DB, then do the math.
If you want to buy an updated database, I've seen it as low at $40. Google is your friend.
Let me know if you need help with the math -- I've got some VBScript lying around here somewhere that'll do the trick and if you use a different lang. -- no prob, the concept translates.
Have fun!
Shawn
phpclasses.org has some classes, code and sample data on how to do this.
visit phpclasses.org - search for zip
see what you find
m00



Couldnt find the code on phpclass.org, but since I already wrote the code myself its cool.
On another note, how does that site highlight a row in a table when i mouseover that row?





http://www.sitepointforums.com/showt...threadid=59665Originally posted by jkh1978
On another note, how does that site highlight a row in a table when i mouseover that row?
http://www.sitepointforum.com/showth...threadid=50826
Hope this is what you're looking for?
-Helge
i guess this will help you:
http://www.cryptnet.net/fsp/zipdy/
from the website:
hope this helps you,Zipdy is a program for calculating the distance between two zip codes and finding all the records in a RDBMS with a zip code with x miles of another zip code. Currently, RDBMS support exists for postgreSQL. Additional future support for other databases will be added in future releases of zipdy.
Zipdy is free software released under the terms of the GNU General Public License. Zipdy was written in C but is also available in PHP and perl. It runs with data from the US Census Gazetteer program. The original Gazetteer data is available here. The data is from the 2000 census.
The distance calculations are made by doing a great circle calculation on longitude and latitude points provided by the census data. The result is returned in standard miles. If you need an explanation of what a great circle distance calculation is, click here.
Tom
Moved to a more appropriate forum
Sean![]()
Harry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
Seanf -- not sure where you moved this, but I got a question regarding how to calculate zipcodes ranges given latitude and longitude and I think it will be helpful here if anyone should search the forum for it:
Jeff,Originally Posted by jsk137
I did mine in VBScript for an ASP application, but a couple minutes on Google (php zip radius) produced the following -- which is exactly what I found for ASP:
PHP Builder
and
dbforums
They both have good explanations. Here's my (rough) VBScript version fwiw (I'm leaving out declaring variables and actual sql):Let me know if that doesn't make sense or if I can clarify.Code:'FIRST FIND THE LAT AND LON FOR THE ZIPCODE 'SUBMITTED BY THE USER 'SQL GOES HERE ' THIS VARIABLE SETS THE RADIUS IN MILES 'iRadius = 30 LatRange = iRadius / ((6076 / 5280) * 60) LongRange = iRadius / (((cos(cdbl(istartlat * 3.141592653589 / 180)) * 6076.) / 5280.) * 60) LowLatitude = istartlat - LatRange HighLatitude = istartlat + LatRange LowLongitude = istartlong - LongRange HighLongitude = istartlong + LongRange 'USE HIGH AND LOW LAT AND LON TO SELECT ZIP CODES 'THAT FALL IN THOSE RANGES 'SQL - select zip where lat <= lowlat and late <= highlat and long >= lowlong and long <= highlong





Just curious; that formula is based on the approximation that the earth is a sphere (not flattened)?
I mean, if I want to calculate something near the zip code for Santa Claus at the north pole, the formula will give me an (a bit) incorrect result?
2nd: The numbers (6076 / 5280) * 60 ? Are they supposed to be equal to 24900 / 360 (the length of 1° in miles) ?





TuitionFree — a free library for the self-taught
Anode Says... — Blogging For Your Pleasure
1. Exactly -- this formula will not give a precise measurement. As I understand it, the old school way of getting lat and lon for the zip was based on the location of the post office -- inherently inaccurate. I haven't figured out Zip Code Tabulation Areas (ZCTA's) b/c I only needed this for a reference application. Also, it wasn't necessary to have precise measurement of pt. to pt. distances.Originally Posted by jofa
2. Yes again.
I know there are more accurate ways of doing this, but if you just need a yardstick, this is as good as any. I'd love to see this done with the new ZCTA's and such.
Phat... now all we need is an open source implementation!Originally Posted by anode
I wanted to follow up on this thread b/c I've figured out ZCTA's for a new project I'm working on. Thank the Census Bureau again for this gem.
Zip, Lattitude and Longitude in handy ascii format:
http://www.census.gov/geo/www/gazetteer/places2k.html
There are four files available. The one you'll be interested in is the ZCTA file.
"The ZCTA file contains data for all 5 digit ZCTAs in the 50 states, District of Columbia and Puerto Rico as of Census 2000. The file is plain ASCII text, one line per record."
Unfortunately, the ZCTA file doesn't have city/town/village names, just zip codes, lat, lon. AND, the schmucks didn't include the FIPS code so you can't import the places and zcta files into tables and join them to get the city/town/village name. Still, it's way more up-to-date than the 1990 data I reference above -- and, again, the price is right.
Enjoy!
I know this thread hasn't been touched upon for a while but I have a few files that contain all the zip codes (with city names and states) in the US (AK and HI included). I also have a piece of PHP code that creates a MySQL table with zip codes and LATS & LONGS. Is that what was being sought?
Yes, I believe that is exactly what they are looking for.Originally Posted by Everah
ssegraves [at] gmail.com
On Image Use, Abuse, and Where We're Headed
stephan | XMLHttpRequest Basics
flickr | last.fm | Cogentas, LLC
Bookmarks