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 have a data set that includes a list of zip codes. Is there a way in R to convert these zip codes to latitude and longitude coordinates?

share|improve this question is a nice place for getting individual coordinates for a single zip code... – user43330 Dec 25 '14 at 0:32
up vote 14 down vote accepted

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:

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:

share|improve this answer
Census Bureau link is broken. It probably referred to ZCTAs which are a census bureau invention. Originally based on zipcodes (which are NOT polygons and regularly change) these are polygons that are intended to be fairly constant. Ie. making them more usable for demographic purposes. – winwaed Jun 23 at 13:31

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

share|improve this answer

I use the geocode function in the ggmap package.

share|improve this answer
will this allow zip+4 or does it only use zip centroids? – B_Miner Jun 22 '12 at 17:49
It's using Google Maps, so works however Google would. (Only get a limited number of geocodes per day.) – Wayne Jun 22 '12 at 17:50
...and apparently you aren't allowed to store the data (you'd basically have to query the API about every time you need it) – Matt Jun 22 '12 at 19:09
Do they mean you can't store them for future geocoding (i.e. creating your own cache of mappings), or that you can't store the results at all? I've used it to locate crimes in my neighborhood and certainly store the Lat/Lon of each crime for future reference. I haven't created a cache that I use to avoid Google for future geocoding, though. – Wayne Jun 22 '12 at 19:40
My reading of the TOS (thanks for the link!) is that they have to do with the presenting of maps to other people. That is, you can't make your own map service that uses Google as a back end and doesn't credit them. It doesn't appear to have anything directly to do with geocoding data. Though who knows in this litigious era... – Wayne Jun 22 '12 at 21:08

Seems like you are using Ruby on Rails
Try this tutorial from Ryan Bates
I've tried it before and it works perfectly. When you type address or zipcode , it will show the longitude and latitude. Hope it works for u too


share|improve this answer
He is asking for a solution in R, not Ruby on Rails. – Fezter Dec 3 '12 at 3:39

Your Answer


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.