title: read tiff file directly to numpy array without saving to disk
body: <p>I often download (geo) tiff files, save them to a temporary disk space, then read in the data using <a href="https://github.com/mapbox/rasterio" rel="nofollow noreferrer">rasterio</a> to get a <code>numpy.ndarray</code> that I can then analyze.</p>
  
  <p>For example, using <a href="https://gis.apfo.usda.gov/arcgis/rest/services/NAIP/Montana_2015_1m/ImageServer/exportImage?f=image&amp;bbox=-12254049.546523554,5821468.735961318,-12201729.385850716,5874434.671211511&amp;imageSR=102100&amp;bboxSR=102100&amp;format=tiff&amp;pixelType=U8&amp;size=512,512&amp;interpolation=%20RSP_BilinearInterpolation" rel="nofollow noreferrer">this url for NAIP imagery</a>:</p>
  
  <pre><code>import os
  from requests import get
  from rasterio import open as rasopen
  
  req = get(url, verify=False, stream=True)
  if req.status_code != 200:
      raise ValueError('Bad response from NAIP API request.')
  temp = os.path.join(os.getcwd(), 'temp', 'tile.tif')
  with open(temp, 'wb') as f:
      f.write(req.content)
  with rasopen(temp, 'r') as src:
      array = src.read()
      profile = src.profile
  os.remove(temp)    
  </code></pre>
  
  <p>For other (netcdf) geographic gridded data, I might use <a href="https://xarray.pydata.org/en/stable/" rel="nofollow noreferrer">xarray</a> to get data
  from <a href="http://thredds.northwestknowledge.net:8080/thredds/ncss/MET/pet/pet_2011.nc?var=potential_evapotranspiration&amp;north=49.1&amp;west=-116.4&amp;east=-103.0&amp;south=44.3&amp;&amp;horizStride=1&amp;time_start=2011-01-01T00%3A00%3A00Z&amp;time_end=2011-12-31T00%3A00%3A00Z&amp;timeStride=1&amp;accept=netcdf4" rel="nofollow noreferrer">this url to get Gridmet data</a>:</p>
  
  <pre><code>from xarray import open_dataset
  
  xray = open_dataset(url)
  variable = 'pr' # precipitation
  subset = xray.loc[dict(lat=slice(north, south),
                         lon=slice(west,east))]
  arr = subset.variable.values
  </code></pre>
  
  <p>So getting an xarray object works as a stream and is easy to get into an <code>ndarray</code>, but I only know of this working on netcdf datasets.  Is there a way to 'stream' in tif data to an <code>ndarray</code> object?  Ideally, one could do this with </p>
  
  <pre><code>with rasopen(url, 'r') as src:
      array = src.read()
  </code></pre>
  
  <p>as <code>rasterio</code> returns a nice metadata object along with the <code>ndarray</code>, though I have not gotten that to work with a url resource.  Thanks.</p>