The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

US zip codes question.

I have a question about US zip codes; do the normal geographic ones[1] lie exactly within states? (In other words, are there zero zip codes who cover geography in more than one state.)

I'm writing some code which needs geographic subdivisions of states, and zip codes would be nice to use if (and only if) each zip code belongs to exactly one state..


[1] I'm figuring there are ones for "Santa" and so on which don't correspond to physical locations.
Katie Lucas
Thursday, June 21, 2007
I think so

To make sure, you could download a list of ZIP codes per state, for example from here, and check for duplicates.
Yury @ Xtransform Send private email
Thursday, June 21, 2007

According to this web site <>:
"For example, most Zip codes in major cities have alternate acceptable names. Some Zip codes cover ten or more communities. Zip codes can span more that one county, or can cross state lines. One Zip code can serve the same city in more than one county."

This thread in Google Groups seems to back this up:

Sorry :(
Former COBOL Programmer
Thursday, June 21, 2007
If you ever look at the actual zip code data, every one has a geographic "center".  You can see this by dropping some into Google Maps or whatever.  Therefore, if you wanted to be able to group, you should be able to without too much problem despite the fact that a few span state lines.
KC Send private email
Thursday, June 21, 2007
We have a local zip code that is for the Pennsylvania State University (16802) which is totally surrounded by one of the State College (yes ... that's a city name) zip codes (16801).

So you'll also need to allow for zips that enclose zips.
Steve Moyer Send private email
Thursday, June 21, 2007
>[A]re there zero zip codes who cover geography in more than one state?

There are more than zero that cross state boudaries.
Peter Send private email
Thursday, June 21, 2007
There are few enough such zip codes that you could build a table of exceptions. In fact, as I recall, in most cases the zip codes are continuous: if x is the minimum zip code for a state p and z is the maximum, then the state is also p for every zip code y such that x <= y <= z.

from the zip code FAQ at

Can ZIP Codes cross State, County, political jurisdictions (cities, congressional district), and metro areas?

In short, the answer is yes to all of the above.  ZIP Codes rarely cross state lines, but cross county lines as often as 10%. You can see this yourself by viewing a sample ZIP code map
George Jansen Send private email
Thursday, June 21, 2007
Hmm!  I thought the first 2 digits of a Zip code WERE a 'state' code, therefore they couldn't cross State lines.  Live and learn, seems like I was wrong in that.
Thursday, June 21, 2007
Though (in the US), if you use the full 9-digit notation, I believe those are unique to individual states.  In most cases, you can use such a code to narrow it down to the individual street/block that someone lives on.  Unfortunately, most people don't know their 9-digit code (myself included).

I have a buddy that works with the US Postal System and they did a study a few years ago that showed that the vast majority of people under 40 know no more than 3 zip codes... where they live, where they work, and where their parents live (generally because they lived there).  The only time this number increased was when they had only lived in their current home for a few years, then sometimes they knew their previous ones (like their parents).  Interesting stuff.
KC Send private email
Thursday, June 21, 2007
"Unfortunately, most people don't know their 9-digit code..."

The last four digits of my nine digit zip code have changed three times over the past five years. I'm not sure if the people who send me junk mail have errors in their mailing lists and the post office manages to deliver in spite of those errors, or if the changes reflect the rapid growth in my area.

It's not relevant to the original poster's question but the idea that the zip code system is designed to be somewhat fluid, is rather fascinating.
Thursday, June 21, 2007
Geographic subdivisions of states are called "counties". I'd just use that.

Note that zip codes "derived from the U.S. Census Bureau... (ZIP Code Tabulation Areas)... may be different than the USPS defined zip code delivery routes".
Thursday, June 21, 2007
I have a PO box in my city.  PO Boxes have a different zip code than the rest of the city.

Another case of zip within (surrounded by) a zip.
Thursday, June 21, 2007
>>Geographic subdivisions of states are called "counties". I'd just use that.

In Louisiana, they're "parishes".
aint tellin Send private email
Thursday, June 21, 2007
A number of companies sell products for address cleaning and correction--I can think of First Logic and Group 1. Their software will attribute county and congressional district, and will geo-code good addresses, either to zip-4 centroids or (with an additional subscription) to the rooftop level.

Would it be practical to look into some such package?
George Jansen Send private email
Thursday, June 21, 2007
>>Geographic subdivisions of states are called "counties". I'd just use that.

In Alaska, they're called "boroughs" and "geographical Census Areas".

At one time I was working on a system which used zip codes extensively. I was able to get a data file which mapped individual addresses to zip code, legislative district, court district, borough and several other divisions. Everything can overlap everything else, btw. It was invaluable. I got it from the state division of elections.
Deborah Miller Send private email
Thursday, June 21, 2007
Not all locations in the US have zip codes -- particularly rural areas.  This occurs more frequently than might be expected.  I used to work on software that uses zip codes extensively and this was a common support issue.

Zip codes are intended to assist mail delivery and that's all.  This means they roughly correspond to geographical areas but relying on this will likely bring you all sorts of problems.
SomeBody Send private email
Thursday, June 21, 2007
Zip codes are not meant to be used for geolocation.  This will burn you often enough to make it impractical.

Even the so-called "city name" in a mailing address is really the name assigned to the post office delivering to that area.  Zip codes define the post office and a delivery area within it, nothing more.  Many of them were derived from the earlier "postal zones" within a post office's coverage area.

I dont believe the Vanity Names people try to use for addressing to their communities are entirely legal.  The "city name" is not meant to define a city, town, village, or community.

One thing that *may* hold is that carrier routes do not cross Zipcode boundaries.  I'm not even sure of that anymore, but most people have no clue what their carrier route ID is anyway.
Thursday, June 21, 2007
Cade Roux Send private email
Thursday, June 21, 2007
As to "Vanity Names": what the Postal Service calls an address need not conform to the political entity. For example, address-correction programs meeting USPS standards will and must designate such Milwaukee suburbs as West Allis as Milwaukee. An acquaintance lives in the Maryland town of Garrett Park. She and her fellow residents must pick up their mail at the local Post Office, for the Postal Service considers Garrett Park, like many incorporated and unincorporated areas thereabouts, to be Rockville; they have given up home delivery in return for retaining their Garrett-Parkness.
George Jansen Send private email
Thursday, June 21, 2007
"Geographic subdivisions of states are called "counties""

Yes, but I have a list of zip codes, and I don't have a list of counties...

I'm going to go with the idea of the zip-code centroid. It's good enough for what we need; we just really need to know if people are, for instance, approximately in "north, east, south or west texas".

So lumping zip codes per state "quarter" or "half" will probably do. Until we actually hire a geographer...
Katie Lucas
Friday, June 22, 2007
Which zip codes cross state lines? I don't believe that there are any, but a counter-example would prove me wrong.
Steve Hirsch Send private email
Friday, June 22, 2007
In an effort to waste some lunch hour time, I went looking for ZIP code areas that cross state boundaries.  Apparently there are two kinds of ZIP codes, the census bureau ones and the post office ones.  Basically similar.  The census bureau ones seem to be more of a geographical indicator.

There is a list here: .

A couple of examples:
New Pine Creek, OR 97635 extending into California.
Navajo, NM 87328 extending into Arizona

Maps here: .
Friday, June 22, 2007
>...I thought the first 2 digits of a Zip code WERE a 'state' code...

Almost kind-of. The first 3 digits describe the region, and all mail going to a single 3-digit area will go through a "zone central facility." When I lived in Southern Florida, that would be the West Palm Beach facility for all zip codes starting with 334 (and I think 335 too). Even if you mailed it from one end of the county to another, it went through that building.

>Geographic subdivisions of states are called "counties".
Louisiana uses Parishes.
If you're using census, or some other federal data sources, you use some whacky thing called a "metropolitan statistical area." They used to be called "metropolitan statistical reporting area" but I think they got laughed at for an acronym that was as long as the word it was replacing: city. 

>I don't have a list of counties...
Ask and ye shall receive:
Ok, even if you don't ask. ;)

A zip code that crosses state boundaries does so because the post office across the border is the one that's going to be handling mail for that area. And this sort of thing is only for low population areas.
Peter Send private email
Friday, June 22, 2007
Senthilnathan N.S. Send private email
Sunday, June 24, 2007
Why all 5-digit ZIP Code™ lists are obsolete:
Sunday, June 24, 2007
For zip code purposes, the US is divided into 10 areas, numbered 0 thru 9, beginning in the northeast and moving west.  (The New England area is 0, the west coast is 9).
That's the first digit of the zipcode.

Within each of these areas there are the main postal distribution facilities, numbered 00 thru 99.  That's the 2nd and 3rd zipcode digits.

Each of those distribution centers feed mail to local post offices numbered 00 thru 99.  That's the 4th and 5th digits.

If you use the 9 digit zip code, those extra 4 digits identify your specific postal route.
Richard McBeef Send private email
Tuesday, June 26, 2007
9 digits don't identify a route, they typically identify a drop of point. I once lived in an apartment building that had THREE 9 digit zip codes.

The manager lived in a mini-house that had it's own mail slot.

There were two mail boxes in the parking lot. Each one had a distinct ZIP+4 designation.

Usual result was some 9 digit zip mail would come properly done for my apartment, some for the manager's 9 digit, since that was what came up if you did an address search without an apartment number.

And for Katie: The ZIP codes reflect the postal services routing of mail.

Even the "city" on the address is the name of the post office which serves the address, rather than the municipality where the address is located, just to add to the confusion.
dot for this on
Tuesday, June 26, 2007

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz