R: Handling of sf objects in raster package : <p>Previously I was using <code>raster::crop</code> and <code>raster::mask</code> with shapefiles of class Spatial*, read in using <code>rgal::readOGR</code>. </p>

<p>I am just "upgrading" my scripts to use <code>sf</code> for reading and manipulating polygons. </p>

<h3>raster::crop</h3>

<p><code>raster::crop</code> expects an 'extent' object as second argument. Up to now, this was automatically extracted from a Spatial* object. So I could just do <code>raster::crop(raster, polygon)</code>.<br>
To get this working with an <code>sf</code> object, I can call <code>raster::crop(raster, as.vector(st_bbox(polygon)))</code> as an ugly workaround.</p>

<h3>raster::mask</h3>

<p>Since <code>raster::mask</code> clearly expects a <code>Raster* object or a Spatial* object</code> the only solution was to coerce the <code>sf</code> object back to a Spatial* object using <code>as("Spatial")</code>. </p>

<p>I assume this problem generalized to all <code>raster</code> functions? Did I overlook something or is it just the case that the <code>raster</code> package does not (yet) work with <code>sf</code> objects? </p>
