Fun with zip codes
Noticed via Tara Calashain’s excellent ResearchBuzz, here’s a great site (maps.huge.info) that lets you view zip code outlines in Google Maps. It’s pretty addictive to type in zip codes (assuming you’re in the U.S., and you have the particular bent of mind that makes you enjoy stuff like Google Maps). For the lazy among you, here’s how it looks:

Notice that it’s doing something cool: after you’ve typed in the first zip code, you can type in more zip codes and it will draw multiple zip codes at once.
Suppose you wanted to do stuff like this yourself. First you’d want the Google Maps API. Next, you’d need a list of all the zip codes in the U.S. This is harder than it should be. From http://www.usps.com/ncsc/faq/:
Q: Where can I get a database or directory of all ZIP Codes and/or ZIP+4 codes along with the corresponding city, state, county, etc.? Is there an FTP site for downloading?
A: The information you are seeking is not available via download but is provided through our National Customer Support Center at (800) 238-3150 ….
[and then later] The Postal Service does not maintain any ZIP Code maps. The only related product we have at this time is the TIGER/ZIP+4 File.
And “TIGER/ZIP+4 File” is a link to a 404 page. Oy, thanks a lot! Grrr. Okay, so pop on over to the U.S. Census Bureau. For example, this page has a link to many good resources, including http://www.census.gov/tiger/tms/gazetteer/zips.txt which has a list of zip codes along with the city, state, latitude, and longitude of each zip code (the lat/lon is for the zip code center).
Technically, the Census Bureau calls their data Zip Code Tabulation Areas or ZCTAs. Why? As they put it,
This new entity was developed to overcome the difficulties in precisely defining the land area covered by each ZIP Code.
For example, zip codes represent postal routes and can’t always be represented with polygons. You can almost feel the contempt seething from the Census Bureau toward the U.S. Postal Service. I can believe that when Census and Postal personnel get in the same room, arguments break out and tempers flare. Sort of like Herbert Kornfeld, the Accounts Receivable Supervisor at The Onion that is always rumbling with Accounts Payable.
Okay, where were we? Postal Service: not helpful at all. Census Bureau: a great, easy-to-parse file. Okay, how about the boundary info with the shape of a zip code/ZCTA? How about this: http://www.census.gov/geo/www/cob/zt_metadata.html Oh, snap! Census Bureau 2, Postal Service 0!
Shall we delve a little deeper? Let’s do it; zip codes are fun. By the way, if you’re not a complete and utter nerd, or you don’t have hours to kill digging into files, the huge.info site sells a DVD with cleaner data in an easier format.
Okay, let’s examine the zip code for 94043 (where Google’s headquarters are located). Go to http://www.census.gov/geo/www/cob/z52000.html#ascii and save the file for California and decompress the zip file. The files are available in three formats, but we’re sticking with straight ASCII. Inside the zip file there are two files, a tiny one and a big one. In the tiny one, look for the zip code you’re interested in (94043 in this example):
2465
“94043″
“94043″
“Z5″
“5-Digit ZCTA”
This entry means that in the big file, the zip code 94043 is represented with an ID of 2465. If you look in the big file, you’ll find the data for that polygon in latitude/longitude format:
2465 -0.122065371904532E+03 0.374225573395062E+02
-0.122077973000000E+03 0.374482390000000E+02
-0.122077373000000E+03 0.374500390000000E+02
…. ….
-0.122077973000000E+03 0.374482390000000E+02
END
The first coordinate appears to be the center of the ZCTA, so chop off the first line and the END line and put the resulting lines in a file called 94043. Now fire up gnuplot and type these commands:
set terminal png
set output "94043.png"
set nokey
set title "Zip code: 94043"
set xlabel "Longitude"
set ylabel "Latitude"
set grid
plot '94043' with lines
Alrighty, let’s see how we did. Here’s the zipcode on the original application:

And here’s our Gnuplot map:

There’s just too many fun things to do in the world.
Update: If you enjoy playing with zip codes, Gary Price pointed me to http://www.melissadata.com/Lookups/index.htm where you can look up neat things like demographics and business counts.
Galina Sh. Said,
September 26, 2005 @ 1:41 am
Strangely enough, I was just looking for zipcode to town, state and back information.
zips.txt file is neat, unfortunately outdated at least 5 years. It’s missing “new” zipcodes from both places I happened to live in in the last couple of years (both East and West coast). Makes one wonder how often they shuffle zipcodes around.
Tobias Kluge Said,
September 26, 2005 @ 1:50 am
Hey Matts,
when will you extends these nice more-content containing Google maps to countries outside the US? It would be nice to get some more data for Europe.
Tobias
Andi Said,
September 26, 2005 @ 6:22 am
Particularly interesting because so much demographic data is linked to zipcodes… I’d like to see a smaller granulation but zipcodes work for many things.
michael Said,
September 26, 2005 @ 8:57 am
Much of this has been done before.
Check out
http://www.holovaty.com/blog/archive/2005/05/31/0225/
and
http://www.postalcoded.com
paul Said,
September 26, 2005 @ 9:24 am
hey there
I emailed Research Buzz as well, but in case you have not done multiple requests, it kicks you off after several requests (not sure how many- was not counting) and tells you to come back in 2 hours. It may be doing this via the IP since I cleared cache, cookies, history, etc and still received the same message.
Matt Said,
September 26, 2005 @ 10:10 am
Michael, thanks for the pointers! Looks like that first link pre-dates the Maps API. Back then you had to use the quadtree specification, I think, instead of just giving a polyline with lat/lon coordinates. I’m glad that the API makes it easier. This stuff is just fun.
Harith Said,
September 26, 2005 @ 3:01 pm
Hi Matt
And the winner is …:)
Assuming that number of comments posted per an article represents the visitors wish to see more of the same, here are the Superstars:
One month
Alerting site owners to problems
Filing a reinclusion request
Remove result
Data:
====================================
September 2005
UI fun: Remove result :Comments (51)
AdWords, AdSense, and the Google blog :Comments (8)
Alerting site owners to problems :Comments (60)
Filing a reinclusion request :Comments (60)
Bacon polenta :Comments (39)
Measuring freshness :Comments (15)
One month :Comments (72)
Book Review: The Search :Comments (9)
What’s an update? :Comments (34)
======================================
August 2005
Bloglines :Comments (10)
Dashes vs. underscores :Comments (37)
Seeing nofollow links :Comments (25)
Smart is sexy :Comments (11)
I do not wish my screensaver to lock my computer, thank you. :Comments (11)
Just call me Rick :Comments (6)
UI fun: Better queries :Comments (18)
UI fun: Better snippets :Comments (16)
SEO Mistakes: sneaky JavaScript :Comments (35)
SEO Mistakes: link exchange emails :Comments (18)
=========================================
July 2005
Things to do and eat in Silicon Valley :Comments (14)
Q: Why doesn’t my site show in SafeSearch?, or “Do you hate Metallica?” :Comments (7)
.htaccess 101: how to password protect a directory :Comments (7)
===============================================================
And yes…
“There’s just too many fun things to do in the world.”
Brian Said,
September 27, 2005 @ 10:04 am
Harith’s methodology, whether he realizes it or not, resembles SEO…note that Matt has to approve comments, so the true number is hidden. link: command, anyone?
Victor Caballero Said,
September 27, 2005 @ 11:50 am
The MAPS API is very cool. Does anyone know if there is a way to zoom in and only display the zip code and then map a specific address?
Vincent Said,
September 28, 2005 @ 5:57 am
Hi Matt
When will this technology be extended into the UK? We are real interested in using this for an upcoming project thats in development stage at the moment.
Vincent Said,
September 28, 2005 @ 6:03 am
Sorry I forgot to add to above that will this also be available for commercial use that can be implemented into projects for www and mobile web?
Thanks again.
Bob L. Said,
September 28, 2005 @ 8:04 am
Matt,
Great stuff. Maps is such a cool app that I am brainstorming for a use on our web site.
I was reading an example that was referenced at xml.com and came across this terrific app http://www.housingmaps.com/. If you are searching for a house, as I am, it combines a few of the functions that I already use
1. The property search
2. The mapping of the property
3. The photos of property)
Awesome stuff.
Bob L.
knut Said,
September 28, 2005 @ 1:24 pm
Funny…
ever recognized that “zip-code”, “zip code” and “zipcode” differs in google?
I thought that “zip-code” would be stemmed to “zipcode”. But the results are different. Google is a myth
I love GoogleEarth!
-knut
Harith Said,
October 1, 2005 @ 6:17 am
Hi Matt
Long time no blogging.
C´mon.. say something
Fionn Said,
October 1, 2005 @ 4:04 pm
Totally fascinating now I need some time to play. Now if Google could just build me a widget that would increase my time by 100%!!!.
Matthew Said,
October 3, 2005 @ 10:30 am
> Makes one wonder how often they shuffle zipcodes around.
Quite a lot, actually. I do some work with mail-list management and see evidence of this all the time. Actually, though the source escapes me at the moment, there IS somewhere with the USPS where you can get updated zip databases every month.
Sean Scott Said,
October 3, 2005 @ 10:50 am
anyone seen an example of mapping county bounderies using google map. Or should i be asking how would you go about mapping the borders of a county via google maps.
Gator99 Said,
October 10, 2005 @ 9:47 am
In actual practice, I’ve found that the lon/lat data from the census site (gazateer) is not very accurate. For a commerical application, you’d need better data.
mac Said,
October 11, 2005 @ 2:43 pm
Matt,
I have a question for you. Can you please read this group post then reply?
http://groups.google.com/group/google-sitemaps/browse_thread/thread/c1834900ea40e74e/8ecdca81236b6f57#8ecdca81236b6f57
Thanks,
Mac
mr_tim Said,
October 21, 2005 @ 3:21 am
Think of the fun we could have in the UK if Google stepped up to provide a decent geocoder for us Google Map API fanatics
DDS Web Design Blog Said,
October 21, 2005 @ 7:38 am
wow, that is awesome, i love google maps/google local, so useful…since its release ive stopped using mapquest compeltely, its just too much better than mapquest
John Coryat Said,
October 26, 2005 @ 4:49 am
Matt,
I recently added both city/town and county boundary mapping to the application.
http://maps.huge.info
-John Coryat, author.
Matt Said,
October 26, 2005 @ 12:08 pm
Nice–thanks for mentioning that, John! I love plotting town boundaries..
Brett Said,
October 27, 2005 @ 8:06 am
This is very cool software. I don’t think I have ever seen any kind of software draw out the area that a zipcode falls within. Pretty cool stuff.
Adam Said,
October 30, 2005 @ 3:53 am
Hi Matt,
I have just found great Google Maps site similar to this, but with whole world coverage. Maybe interesting for others as well. See http://www.maplandia.com.
-Adam
Online Dictionary Said,
November 8, 2005 @ 12:01 am
Had been playing with the tigerline database and and the geocoding and i think having it natively in your system seems costly than using the geocode us webservice.
Steve A Said,
November 11, 2005 @ 7:51 am
I have a list of zip codes that I want to display on Google Map (eg, with a marker - I’m not trying to show boundaries). I’d like to show them all at once, not one at a time - have you seen a site that does htis?
victor caballero Said,
November 18, 2005 @ 10:41 pm
I know this is somewhat unrelated to this thread, but I was curious as to why some addresses like this example show up as a different address when mapped by Google.
http://maps.google.com/maps?oi=map&q=301+N+Orange+Grove+Blvd,+Pasadena,+CA+91103
I found it odd and thought there must be an explanation????
Thanks in advance.
Victor
Mike Chau Said,
November 24, 2005 @ 7:34 pm
Does anyone know if there is something simalar for Canada?
Chung Said,
January 4, 2006 @ 6:14 am
I wish they could make that kind of map for Italy aswell. Here in Italy the companies are so lame…
online sudoku Said,
February 23, 2006 @ 6:47 am
I wish they made smoething like this to the UK!!
Mush Said,
March 2, 2006 @ 8:49 am
When does this tool will be available for another countries?
Adam Yax Said,
March 5, 2006 @ 7:20 pm
multi-country zip codes would be helpfull for us as well. If anyone finds one please post.
Edward Said,
March 21, 2006 @ 5:02 pm
We use this tool to verify orders on our mens underwear site http://www.nuwear.com
John Wehr Said,
April 10, 2006 @ 7:55 pm
I’ve made a similar database and associated PHP class available for sale at:
http://zip-code-boundaries.com/
Hopefully it will be useful for companies who want ZIP Code outlines in their web applications.
Amber Said,
October 5, 2006 @ 10:50 am
I have looked the web over for a site that will allow you to insert a zip code, have it mark that zip code on a map, and then save it to the map. Then be able to add another zip code and repeat the procedure. Sort of like planning a route based on zip codes, or taking a list of random zip codes and plotting them on a map. Any help would be great! am
Colin Crawford Said,
November 3, 2006 @ 4:18 pm
Man I wish this was available in Australia. That is such a cool tool to have especially for working out freight charges for distribution.
Expired Domain Names Said,
January 14, 2007 @ 2:11 pm
I wish they made smoething like this to the UK!!
Brian Said,
February 28, 2007 @ 11:50 am
I have a list of zip codes and I want to show their concentration on a map, kind of like a precipitation weather map. How do I do that?
John Said,
May 12, 2007 @ 8:54 am
It helps us to keep orders from coming back as undeliverable our online store for men’s underwear ABCunderwear.com We find it very helpful
Rick Vidallon Said,
May 22, 2007 @ 6:09 am
I searched the regional term ‘Virginia Web Design’ and you displayed the regional results incorrectly.
You show map tag ‘C’ as Ciniva but this should be VISIONEFX.
The same thing happens when you search the local term ‘ Virginia Beach Web Design. You show map tag ‘A’ as Ciniva but this should be VISIONEFX.
Why are the map tags inaccurate?
Jon Said,
May 22, 2007 @ 10:37 am
The post office doesn’t provide the lists of ZIP Codes for download, but there are quite a few companies out there that are licensed to resell the data:
http://www.zipcodedownload.com/
http://www.greatdata.com/
http://www.melissadata.com/
Most of them have databases with latitude and longitude coordinates included.
Simon Said,
July 31, 2007 @ 11:03 am
That’s a cool. I didn’t realize zip codes were so irregular shaped and weird looking. Check out my zip code 90211 and the craxy shaped LA zip codes arount it.
James Said,
September 12, 2007 @ 7:28 pm
I have built a set of tools to work on zip codes. Take a look at http://www.mapszipcode.com. The site is complete but I intend on adding more tools and info as time permits.
Darrin Clement Said,
September 18, 2007 @ 6:40 pm
This is very fun and a great application of map data with Google. Important to remind anyone doing serious analysis though, that ZCTAs are very much not “ZIP Codes”. Commercial companies (like Maponics - http://www.maponics.com - where I work) use much more accurate and current data than ZCTAs. Of course, ZIP Codes are not really polygons anyway - they are collections of houses that have the same ZIP Code, but that’s a whole other story.
Arnie Said,
November 18, 2007 @ 11:15 am
I was just looking for this exact tool for a blog idea I have. Managed to find this post in 10 minutes. I love the web.
US zip code map Said,
January 9, 2008 @ 2:30 am
I would recommend http://www.zipcodesmapped.com/ for any US zip code map.
You can use this to find any US zip code maps. You can search by (City, State OR Zip). they have all the maps showing zip codes and major mile streets in all of the united states. The service is free. Search for five Digit Zip Code and find the Maps for all 50 states. A Free ZIP Code Finder which can do wonders for you.