title: Why do I get negative dimensions are not allowed merging rasterio datasets?
body: <p>I am trying to use Python's rasterio library to analyze GIS wind data available <a href="https://www.nrel.gov/gis/assets/images/us-wind-data.zip" rel="nofollow noreferrer">here</a>. I've written this reduced program:</p>
  <pre><code>import numpy as np
  import rasterio as rio 
  from rasterio.merge import merge
  
  file1 = 'us-wind-data/wtk_conus_120m_mean_masked.tif'
  file2 = 'us-wind-data/wtk_conus_140m_mean_masked.tif'
  
  def f(old_data, new_data, old_nodata, new_nodata, index=None, roff=None, coff=None):
      old_data[:] = np.maximum(old_data, new_data)
  
  with rio.open(file1, dtype=np.float64) as test1, rio.open(file2, dtype=np.float64) as test2:
      mosaic, out_trans = merge([test1, test2], method=f)
      print(mosaic)
  </code></pre>
  <p>and when running this I see:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;merge5.py&quot;, line 16, in &lt;module&gt;
      mosaic, out_trans = merge([test1, test2], method=f)
    File &quot;/home/mmachenry/.local/lib/python3.8/site-packages/rasterio/merge.py&quot;, line 261, in merge
      dest = np.zeros((output_count, output_height, output_width), dtype=dt)
  ValueError: negative dimensions are not allowed
  </code></pre>
  <p>There are a lot of examples of this error on Stackoverflow. None that I've found seem to be what I'm doing. It is, after all, a low level numpy error. In my research I've found people experiencing issues with reading the data as default float16 and then getting math overflow errors producing negatives. So I bumped up my dtype to float64 and it did not improve the situation.</p>
  <p>I'm attempting to write a simple function that will take several of these tif files with a wind speed at each data point and create a new tif file with my data point that is a function of all of the wind speeds.</p>