title: How to retrieve bbox for osmdata from spatial feature?
body: <p>How to define the bbox to download OSM data based on the extent of a spatial file?
  The following example returns an error message:</p>
  <blockquote>
  <p>...the only allowed values are floats between -90.0 and 90.0</p>
  </blockquote>
  <p>This shows that the bbox-values are out of allowed range. It also shows that the convertion between NAD27 and EPSG:3857 did not return the spatial data at place where it should be.
  With other spatial data I had similar problems. Eventhough within allowed range, the data didn't appear at the expected place. Downloaded OSM data appeared at a different place as the input spatial file.</p>
  <pre><code>library(sf)
  library(raster)
  library(osmdata)
  
  osm_proj &lt;-(&quot;+init=epsg:3857&quot;)
  
  nc &lt;- st_read(system.file(&quot;shape/nc.shp&quot;, package=&quot;sf&quot;))
  
  nc &lt;- st_transform(nc, osm_proj)
  
  bbox.nc &lt;- as.vector(extent(nc[22,]))/100000
  
  q &lt;- opq(bbox = bbox.nc) %&gt;%
    add_osm_feature(key = 'natural', value = 'water')
  
  osm.water &lt;- osmdata_sf(q)
  </code></pre>
  <p>How to prepare the bbox that downloaded OSM data matches spatial extend of input spatial file?</p>