iandees / wtf-zipcodes

So you want to map zipcodes...
https://zipcodes.wtf/
MIT License
84 stars 4 forks source link

WTF, Zipcodes?

_Mr. ZIP_

ZIP codes were introduced in the United States in 1963 as a way for the Post Office Department (later reorganized as the United States Postal Service in 1971) to deliver mail more efficiently. This vintage video from 1967 helpfully explains both the problem and solution in musical form. Practically, ZIP codes are often used as a method to denote a general locality on web applications that rely on user location (i.e. nearby restaurants).

ZIP codes are often a source of confusion because they're fundamentally different from other types of location data.

ZIP Codes are sets of points, not areas

Map of the United States with Arkansas highlighted

Area of the state of Arkansas (Licensed CC BY-SA 3.0)

Regions like states, countries, and counties are defined by their borders and when represented as geographic data they are represented as polygons. This means that these regions have area, centerpoints, and a simple way to determine whether a given point is inside or outside of the region.

USPS ZIP Codes are not areal features but a collection of mail delivery routes. -USPS

ZIP Codes are not regions or polygons: they are collections of points. The original purpose of the ZIP Code is to organize mail delivery points into convenient groups for mail carriers, so points are chosen based off of roads and accessibility, not regions.

The final 2 digits of a zip code have very little geographical meaning, but the first 3 do. That said, these aren't guarantees around this meaning: while the first digit tends to identify that a ZIP Code is within a given group of states, it doesn't guarantee that the code stays within a single state.

ZCTAs are approximations of ZIP Codes as areas

Enough people expect ZIP codes to be areas and want to do calculations based on them as areas that the US Census Bureau has created generalized polygon representations called ZCTAs (ZIP Code Tablulation Areas). These are generated by assigning each census block to a ZCTA based upon the most frequent ZIP Code within that block:

zcta

How ZCTAs are born (courtesy U.S. Census Bureau)

There are gotchas in this process, since there are many places in the United States with no addresses, so they don't clearly belong to any ZIP. There are also ZIP codes that are completely unique - buildings and military bases can have their own ZIP even if they're totally surrounded by buildings with a different ZIP.

Geographical Q&A

What ZIP code is this longitude, latitude point within?

Not clearly defined: ZIP Codes contain address points, and are not areas. You can answer this question with either

Given this ZIP Code, what state, congressional district, etc is this person in?

Not clearly defined: ZIP Codes have rough, estimated centerpoints, but are not really a good way to indicate areas. 1

What ZIP code is this address in?

This is clearly defined: every address has a ZIP code, and you can find this with most geocoders.

Notes