-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Negative dimensions in merge arrays #692
Comments
This might be due to a difference in the dimensions of |
Yes, because rioxarray. It works, my point is more that the sign handling of the transforms in code seems inconsistent. |
@RichardScottOZ are you able to provide a simple, reproducible example? |
Will see if I can make one on the weekend. |
Alan, the above is from this, basically: https://github.com/RichardScottOZ/AU-US-CAN-GEOPHYSICS/blob/main/RIOXARRAY-RES-TEST.ipynb |
Note the first version using reproj resolution (e.g. can resolution above) - which equals (0.31, -0.31) fails with the error above ---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[19], line 8
5 usgs['GeophysicsGravity_HGM_USCanada.tif'].name = 'uscan'
7 #auscan = xr.concat([reproj, usgs['GeophysicsGravity_HGM_USCanada.tif']],dim='band')
----> 8 auscan = merge_arrays(dataarrays = [reproj, usgs['GeophysicsGravity_HGM_USCanada.tif']], res = reproj.rio.resolution(), crs="EPSG:4326")
10 auscan
File ~\AppData\Local\miniconda3\envs\pangeo\lib\site-packages\rioxarray\merge.py:174, in merge_arrays(dataarrays, bounds, res, nodata, precision, method, crs, parse_coordinates)
171 rioduckarrays.append(RasterioDatasetDuck(dataarray))
173 # use rasterio to merge
--> 174 merged_data, merged_transform = _rio_merge(
175 rioduckarrays,
176 **{key: val for key, val in input_kwargs.items() if val is not None},
177 )
178 # generate merged data array
179 representative_array = rioduckarrays[0]._xds
File ~\AppData\Local\miniconda3\envs\pangeo\lib\site-packages\rasterio\merge.py:293, in merge(datasets, bounds, res, nodata, dtype, precision, indexes, output_count, resampling, method, target_aligned_pixels, dst_path, dst_kwds)
290 out_profile["nodata"] = nodata
292 # create destination array
--> 293 dest = np.zeros((output_count, output_height, output_width), dtype=dt)
295 if nodata is not None:
296 nodataval = nodata
ValueError: negative dimensions are not allowed but giving it (0.31, 0.31) succeeds |
I can chop out a tiny uploadable piece of this that will do the same if you want. Haven't got as far as tinkering with rioxarray to throw in some print debugs for running the above to see but I remember some abs() call branches in there. |
EDIT: this comment was incorrectly posted, moved to #174 (comment) |
@veenstrajelmer, I don't think your example is related to this discussion. I believe that it is more closely related to: #174 |
This is odd, that was the issue where I thought I commented, but I guess I clicked a different link in the meantime. I moved my comment to that discussion. Sorry for the confusion. |
Problem description
Looking at the merge code there are some abs() checks in there - but are you supposed to be able to do the above? There is a da_res assigned with absolute resolutions and a res check used later.
Expected Output
Environment Information
The text was updated successfully, but these errors were encountered: