Nearest zip code of a zip code?
Asked Answered
D

6

15

I need to find the 5 nearest zip code of a zip code. For example, I have 33304, and I need to find the nearest ones, like 33309, 33308 ...

Is there a database or a web service somewhere that would help me with that?

I think I'm gonna have to build my own database in order to do that? I know how to do it, but in case it has already been done ...

Denounce answered 13/9, 2010 at 22:55 Comment(0)
O
13

what country? Maybe you want to checkout Geonames: http://www.geonames.org/

Especially: http://www.geonames.org/export/web-services.html#findNearbyPostalCodes

Odelle answered 13/9, 2010 at 23:1 Comment(5)
This is exactly what I was looking for, I know geonames.org but I totally forgot to have a look at itDenounce
geonames.org/export/web-services.html#findNearbyPostalCodes link is not working for me. Thanks.Pool
Do any of you know if there is a downloadable version of this?Abdication
@TylerRutt you could download the raw data (download.geonames.org/export/zip), import it in a database and use a radius search query. Google "points in radius <put database name here>"Odelle
is geonames free? and is it possible to determine the closest coordinate to a given postal code that the user inputs?Dorothadorothea
F
8

This answer is in response to the recent bounty requesting a location of US Zip Codes.

The United States Census Bureau has a list of zip codes (with latitude and longitude) on their web site.

The zip code tabulation areas is a CSV that contains (as described in the description of the file format), among other fields:

Column 1    GEOID   Five digit ZIP Code Tabulation Area Census Code
...
Column 6    INTPTLAT    Latitude (decimal degrees) First character is blank or "-" denoting North or South latitude respectively
Column 7    INTPTLONG   Longitude (decimal degrees) First character is blank or "-" denoting East or West longitude respectively

I'd cross reference the above, with data from the Census Bureau's county business patterns CSV to get city, state and county names. This file format is described to contain (among other fields) (description is in the file you select to download):

ZIP             C       ZIP Code
NAME            C       ZIP Code Name
...
CITY            C       ZIP City Name
STABBR          C       ZIP State Abbreviation
CTY_NAME        C       ZIP County Name
Fete answered 10/8, 2015 at 14:46 Comment(0)
W
3

Here is a free web service to do exactly what you need: http://www.zipwise.com/webservices/

Workaday answered 8/2, 2013 at 17:59 Comment(2)
zipwise seems more reliable than geonames.org.. do you know how long they have been around?Wellfixed
According to the site, "Since 2002"Workaday
T
2

I tested geonames and did not find it good enough. Test areas near your zip code and you will not find all the zipcodew. These have good results but have not found any API yet http://www.searchbug.com/tools/zip-radius.aspx

Thurber answered 24/10, 2011 at 19:24 Comment(1)
You will not find any free data sources that are up to date. You have to pay for current data, in my experience.Workaday
A
2

For the nearest ZIP Code, there are two approaches: find contiguous (adjoining) ZIP Codes and/or find the nearest ZIPs based on the distance from the center of one ZIP Code to the center of another, based on latitude and longitude.

To choose the contiguous ZIP approach, you will need ZIP Code Boundaries data. Alignstar makes one that we're very pleased with (we resell it), but ESRI and a couple of other companies have good products as well. My company, GreatData.com, developed a contiguous counties product and could develop a contiguous ZIP Codes product, but so far, nobody has been asking for it. This could be a data file or an API.

To find the nearest ZIP Codes based on centroids (latitude / longitude center points of the ZIP Code), you will need a ZIP Code Database with latitude / longitude data (we provide one, or go here for links to some free resources: //http://uszipcodes.com/free-zip-code-lookup.htm. If you just want an API and not the hassle of doing it yourself, let us know. We've started to develop similar APIs and will develop based on the demand.

One caveat of doing this by the centroids: we've seen in the past where if you have a large (or long), adjoining ZIP, the center of that ZIP could be farther away than another small ZIP Code, so your list of the 5 nearest could miss an adjoining ZIP.

Almshouse answered 24/9, 2012 at 14:57 Comment(0)
B
0

PostgreSQL has new feature in 9.1 called "KNN". It is specifically for "Nearest Neighbor" distance searches, and from benchmarking and testing it it myself, it is very fast, and can be used for zipcodes. Here is a quick introduction to KNN.

You can also find a thread about applying KNN to zipcodes, and a more recent follow-up.

Brew answered 3/11, 2011 at 19:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.