title: Extract centroid of shape file object in R?
body: <p>I have a shape file, uploaded at the following path:</p>
  
  <p><a href="https://drive.google.com/open?id=0B1ITb_7lHh1EUFVfVWc4ekRfSnc" rel="nofollow">https://drive.google.com/open?id=0B1ITb_7lHh1EUFVfVWc4ekRfSnc</a></p>
  
  <p>I imported the data using the "read.shapefiles" function in "shapefiles" package:</p>
  
  <pre><code>landuse&lt;- read.shapefile("landuse")
  </code></pre>
  
  <p>I now need to extract the lat/long centroids of all the shapes within the landuse object and add it to the landuse$dbf dataframe</p>
  
  <p>I tried two things:</p>
  
  <pre><code>lu_df&lt;-coordinates(landuse)
  lu_df&lt;-SpatialPoints(landuse)
  </code></pre>
  
  <p>Both gave me the following error:</p>
  
  <pre><code>Error in coordinates(as.data.frame(obj)) : 
    error in evaluating the argument 'obj' in selecting a method for function 'coordinates': Error in data.frame(record = 1L, content.length = 80L, shape.type = 5L,  : 
    arguments imply differing number of rows: 1, 4, 7
  </code></pre>
  
  <p>I am not sure on how to proceed.</p>