How to convert zip codes to latitude and longitude?

There's no strict algorithmic relationship between latitude and longitude and zip code - they're all custom areas generated by the postal service. You need access to a dataset that codes polygons / polygon centroids by zip code.

1) Complex

Traditionally, this task (coupled with address lookup) is termed 'Geocoding'. The most convenient method for full address lookup is to find a preexisting online geocoder, whether by Google Maps, Bing Maps, or ESRI.

2) Simpler

For just US zip codes, though, there is data available from the Census:

http://www.census.gov/geo/www/cob/z52000.html

I'm not familiar with R geospatial capability, but all you should need is polygon->centroid, and centroid->coordinates.

3) Simplest

This task is common enough that a preexisting centroid dataset exists: http://coolthingoftheday.blogspot.com/2008/04/free-us-zip-code-database-as-csv.html


have you looked at the zipcode package? it's basically a dataframe with ~45,000 zipcodes along with their city, state, latitude and longitude.


I use the geocode function in the ggmap package.