title: Converting polygons into latitude and longitude in R/Excel
body: <p>I have a data set about all the counties in Minnesota, and one of the columns is its shape. For each county it looks something like this:</p>
  
  <p>For Aitkin County:</p>
  
  <pre><code>    &lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;-93.051956,46.15767700000001,0 -93.434006,46.15313,0 -93.43261,46.240253,0 -93.80480900000001,46.23817100000001,0 -93.80933400000001,46.580681,0 -93.77426199999999,46.59050400000001,0 -93.77412400000001,46.802605,0 -93.77500100000002,47.030445,0 -93.058258,47.022362,0 -93.05964600000001,46.766071,0 -93.05208600000002,46.417576,0 -93.051956,46.15767700000001,0&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;
  </code></pre>
  
  <p>I'm fairly new to R and know nothing about Google API, HTML, etc. I'm trying to use the ggplot2 and maps packages to create an intensity map for various aspects of all the counties in Minnesota. Is there a way to use these coordinates as they are to make a layer of counties, or do I need to do something else?</p>
  
  <p>Here's the code I have so far:</p>
  
  <p>Map of MN:</p>
  
  <pre><code>    library(maps)
      library(ggplot2)
      all_states &lt;- map_data("state")
      mn&lt;-subset(all_states, region %in% c("minnesota"))
      p&lt;-ggplot()
      p&lt;-p+geom_polygon(data=mn, aes(x=long, y=lat, group=group), colour="black", fill="white")
      p
  </code></pre>
  
  <p>And my plan is to modify the following to apply to each county, once I get those polygons:</p>
  
  <pre><code>    dataset &lt;- data.frame(region=states,val=runif(49, 0,1))
      us_state_map &lt;- map_data('state')
      map_data &lt;- merge(us_state_map, dataset, by='region', all=T)
      map_data &lt;- map_data[order(map_data$order), ]
      (qplot(long, lat, data=map_data, geom="polygon", group=group, fill=val)
      + theme_bw() + labs(x="", y="", fill="")
      + scale_fill_gradient(low='#EEEEEE', high='darkgreen')
      + opts(title="Title",
      legend.position="bottom", legend.direction="horizontal"))
  </code></pre>
  
  <p>Any suggestions would be greatly appreciated!</p>