0

I currently have a list of counties that I am trying to map using library(ggmap) and library(ggplot2) in California. I have looked and cannot seem to find any tables that match a central latitude and longitude value for the given counties.

Is there an R package that will allow me to do this? Or even just table I can join onto with my current data table? Below is an example of what I want, except substitute zip for county.

library(zipcode)
data(zipcode)
head(zipcode)

 zip       city state latitude longitude
1 00210 Portsmouth    NH  43.0059  -71.0132
2 00211 Portsmouth    NH  43.0059  -71.0132
3 00212 Portsmouth    NH  43.0059  -71.0132
4 00213 Portsmouth    NH  43.0059  -71.0132
5 00214 Portsmouth    NH  43.0059  -71.0132
6 00215 Portsmouth    NH  43.0059  -71.0132
cgage1
  • 579
  • 5
  • 15
  • Does [this](http://stackoverflow.com/a/26580668/496488) or [this](http://stackoverflow.com/questions/9441778/improve-centering-county-names-ggplot-maps) help? – eipi10 Mar 07 '16 at 22:43
  • Thanks! @jenesaisquoi `geocode` worked great. I just had to paste ", CA" at the end of each county name, and `geocode` produced the long and lat that I needed. – cgage1 Mar 07 '16 at 23:06
  • @eipi10 Those looked to be helpful but I had trouble installing the packages for whatever reason. Never the less, `geocode` solved my problem. Thanks anyways! – cgage1 Mar 07 '16 at 23:07
  • 1
    If you download the shapefiles for the counties in California, you can calculate the centroids like this: http://gis.stackexchange.com/questions/43543/how-to-calculate-polygon-centroids-in-r-for-non-contiguous-shapes – cory Mar 08 '16 at 13:22

0 Answers0