Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a zip code listing, and I am curious to know how many (or which) zip codes map to more than one US state or US city?

For instance I know that 42223 resolves to the same city which straddles the KY-TN state line.

BTW googleapi only returns the TN city for that zip oddly enough.

share|improve this question

There really isn't a way to tell this; since there is not a ZipCode boundary shape that is defined by the USPS. ZipCodes are defined by a bounding box of Streets delivered to by carriers from a particular distribution center.

So you would need to take the USPS AIS data and extract by ZipCodes the streets that are delivered by a given Post Office, then Join these a street grid. This is what all the commercial vendors do (Nokia/TomTom) to create the Psuedo shape that they use to show postal boundaries.

This inexact process is the reason why the USPS does not provide spatial data.

share|improve this answer
    
Is anything accurate? What is truth? Lots of zip boundaries layers have been created, which may or may not serve the purpose of this particular analysis given its unknown requirements. Esri free zip boundaries --arcgis.com/home/item.html?id=8d2012a2016e484dafaac0451f9aea24 See also gis.stackexchange.com/questions/2682/… – awesomo Mar 8 '13 at 22:30
2  
Given, but you also need to understand whatever you are doing the implications of the data you use. – D.E.Wright Mar 9 '13 at 0:08

There are 13 multi-state US Census' ZIP Code Tabulation Areas (ZCTAs): 02861, 42223, 59221, 63673, 71749, 73949, 81137, 84536, 86044, 86515, 88063, 89439 & 97635.

As others have mentioned, there are a few different ways to figure out the area covered by a ZIP Code, but ZCTAs are the easiest, and the only official version that I know of.

So your example of 42223 does span a state border, but it looks like it is actually between Maryland and Virginia. that between Kentucky and Tennessee.

Here's the full list with states:

 02861  Massachusetts
 02861   Rhode Island
 42223       Kentucky
 42223      Tennessee
 59221        Montana
 59221   North Dakota
 63673       Illinois
 63673       Missouri
 71749       Arkansas
 71749      Louisiana
 73949       Oklahoma
 73949          Texas
 81137       Colorado
 81137     New Mexico
 84536        Arizona
 84536           Utah
 86044        Arizona
 86044           Utah
 86515        Arizona
 86515     New Mexico
 88063     New Mexico
 88063          Texas
 89439     California
 89439         Nevada
 97635     California
 97635         Oregon

Here's how I generated it (with Pandas in Python):

import pandas as pd

zcta_to_place_url = 'http://www2.census.gov/geo/docs/maps-data/data/rel/zcta_place_rel_10.txt'

# load relevant data
df = pd.read_csv(
  zcta_to_place_url,
  dtype={'ZCTA5': str},
  usecols=['ZCTA5', 'STATE'])

# the data often repeats the same (ZCTA, state) pair. Remove these
df = df.drop_duplicates()

# get number of times each ZCTA appears (most are only 1)
counts = df['ZCTA5'].value_counts()

# get those listed more than once
multi_state_zips = df[df.ZCTA5.isin(counts[counts > 1].index)]


# the census uses numeric state codes
# replace these with state names

census_codes_to_names_url = 'http://www2.census.gov/geo/docs/reference/state.txt'

states = pd.read_csv(census_codes_to_names_url, sep='|')
merged = pd.merge(
  multi_state_zips, states,
  on='STATE'
  )[['ZCTA5', 'STATE_NAME']]
print merged.sort(['ZCTA5', 'STATE_NAME']).to_string(index=False)

Edit: It seems the Census has two different two-digit codings for states. Both are numbers assigned based on the state's alphabetical ordering, but one seems to apply the numbers directly from 1-51 (50 states + DC), while the other skips some numbers. I was using the first, while I should have been using the second, so the state names I listed were wrong. I've updated the code and results with the correct list.

Edit: new state mapping confirmed by the OpenCongress API: https://gist.github.com/gabrielgrant/89f883d093e2abf129ad

share|improve this answer
    
South Carolina and Colorado sharing a zip code suggest a data and/or processing error. – Jesse Crocker Oct 22 '15 at 2:32
    
That is a good point, it seems most of them don't make much sense... Looking into it now. – Gabriel Grant Oct 22 '15 at 2:49
    
According to the Sunlight Labs API, the ZCTAs I've found are correct, but the State names are wrong. It looks like the problem may just be in the numeric ID -> state name mapping, but I haven't yet found another source for how these numeric IDs are related to state names. – Gabriel Grant Oct 22 '15 at 10:10
    
Thanks a lot for catching this @JesseCrocker - It seems the Census (confusingly) has two different two-digit codings for states. Both are numbers assigned based on the state's alphabetical ordering, but one seems to apply the numbers directly from 1-51 (50 states + DC), while the other skips some numbers. I was using the first, but I should have been using the second, so the state names I listed were wrong (though the ZCTAs were good). I've fixed the code and results with the correct list. – Gabriel Grant Oct 22 '15 at 10:42
    
Regarding the gaps in the FIPS codes, the skipped numbers were reserved in the 1970s for outlying territories (American Samoa, Canal Zone, Guam, Puerto Rico, and Virgin Islands), but then didn't end up being used for them. en.wikipedia.org/wiki/… – neuhausr Jan 7 at 14:41

The US Census Bureau derives approximate boundaries for ZIP codes based on the addresses contained within them, called ZIP Code Tabulation Areas (ZCTAs).

They publish relationship files that describe how their ZCTAs map to various other geographies. If you examine the ZCTA to Place relationship file you can see how they map to cities and towns. You can infer how they map to states from the ZCTA to Counties relationship file.

The relationship files use Census geography IDs, so you'll want to grab a gazetteer file to help you convert the numeric IDs into the place or county names you're expecting.

As other answers have stated, any mapping of ZIP codes to places is likely to be approximate, but I've had good luck with the Census data files.

share|improve this answer

With ArcGIS you can use the spatial join tool (or in a script) to find which zip code polygons intersect with more than one state polygons. In the output feature class, there will be a Join_Count field that will indicate multiple states. You could do a similar thing with zips and cities. There will likely be false positives where the zips unintentionally overlap more than one because of border inaccuracies/lack or resolution. You could possibly do a negative -100m buffer of the zips before the spatial join and see what that does.

import arcpy

target_features = "C:/data/usa.gdb/states"
join_features = "C:/data/usa.gdb/zips"
out_feature_class = "C:/data/usa.gdb/states_zips"

arcpy.SpatialJoin_analysis(target_features, join_features, out_feature_class, "JOIN_ONE_TO_MANY")

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Spatial_Join/00080000000q000000/
"Two new fields, Join_Count and TARGET_FID, are always added to the output feature class. Join_Count indicates how many join features match each target feature (TARGET_FID). Another new field, JOIN_FID, is added to the output when JOIN_ONE_TO_MANY is specified in the Join Operation parameter."

share|improve this answer

You can do a spatial intersect in PostGIS and get a list back of every State or City and the Zip Codes that they intersect, which would return multiple zip codes where multiple states intersect, and for each city that intersected the same zip, you would see that result as well.

share|improve this answer

Don't forget zipcode 57717 which spans three states six, counties, and multiple cities:

57717 Aurora, SD 57717 Butte, SD 57717 Carter, MT 57717 Crook, WY 57717 Harding, SD 57717 Lawrence, SD

share|improve this answer

According to the following U.S. Census Bureau site there are 153 zip codes that cross state boundries.

https://www.census.gov/population/www/documentation/twps0007/twps0007.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.