title: Error whilst performing gCentroid in R
body: <p>I am unable to get centroids from polygons in R. The confusing bit is, it used to work in the past and has suddenly stopped working! This is the piece of code:</p>
  
  <pre><code>polygon.centroids &lt;- SpatialPointsDataFrame(gCentroid(polygon, byid = TRUE), 
                                        polygon@data, match.ID = FALSE)
  </code></pre>
  
  <p>I can also confirm that the proj4string for the polygon data already exists and is as follows:</p>
  
  <pre><code>proj4string:    +proj=utm +zone=55 +south +ellps=GRS80 +units=m +no_defs
  </code></pre>
  
  <p>The error message that I am getting upon executing the centroids code is as follows:</p>
  
  <blockquote>
  <pre><code>   Error in TopologyFunc(spgeom, id, byid, "rgeos_getcentroid") : 
    no slot of name "proj4string" for this object of class "sf" 
  </code></pre>
  </blockquote>
  
  <p>Any idea what's going on? As mentioned earlier, this code HAS WORKED OKAY in the past.</p>
  
  <p>Thanks</p>