title: Get data frame with polygons id and Centroid (lat long) information from shapefile
body: <p>I have a polygon shapefile (downloadable <a href="ftp://dnrftp.dnr.ne.gov/pub/data/state/Legislative2010UTM.zip" rel="noreferrer">here</a>) from which I want to create a <code>data.frame</code> with 3 columns containing:</p>
  
  <ol>
  <li>Polygon id </li>
  <li>Centroid latitude</li>
  <li>Centroid Longitude</li>
  </ol>
  
  <p>From this answer <a href="https://stackoverflow.com/questions/26580129/calculate-longitute-latitude-for-geographic-centroid">here</a>, I know it its quite easy to get this information as a <code>Formal Class SpatialPoints</code> object. And when I convert this object to a data.frame I loose the id information.</p>
  
  <pre><code># Load Shapefile
    Legislative_areas &lt;- readOGR(dsn = 'C:/Users/.../Downloads/Legislative2010UTM', layer ='Legislative2010UTM')
  
  # Get centroids
    cent &lt;- gCentroid(Legislative_areas, byid=TRUE)
  
  # Convert to data.frame, but loose id info
    cent &lt;- as.data.frame(cent)
  </code></pre>
  
  <p>Any idea on how to keep the id info?</p>