Description
During a full run of test_case_by_hydro_id.py, pointing against previous_fim/hand_4_8_6_1, it was able to process some hucs but failed on huc 05130205.
Processing 05130205_usgs (66 of 269)
CRITICAL Execution failed
CRITICAL Traceback (most recent call last):
File "//foss_fim/tools/test_case_by_hydro_id.py", line 418, in
catchment_zonal_stats(benchmark_category, version, output_file_name)
File "//foss_fim/tools/test_case_by_hydro_id.py", line 282, in catchment_zonal_stats
stats = perform_zonal_stats(catchment_gpkg, agree_rast)
File "//foss_fim/tools/test_case_by_hydro_id.py", line 44, in perform_zonal_stats
stats = zonal_stats(huc_gpkg, {"agreement_raster": agree_rast}, nodata_value=10)
File "/foss_fim/tools/pixel_counter.py", line 199, in zonal_stats
src_array = rb.ReadAsArray(*src_offset)
File "/usr/lib/python3/dist-packages/osgeo/gdal.py", line 5321, in ReadAsArray
return gdal_array.BandReadAsArray(self, xoff, yoff,
File "/usr/lib/python3/dist-packages/osgeo/gdal_array.py", line 643, in BandReadAsArray
if BandRasterIONumPy(band, 0, xoff, yoff, win_xsize, win_ysize,
File "/usr/lib/python3/dist-packages/osgeo/gdal_array.py", line 256, in BandRasterIONumPy
return _gdal_array.BandRasterIONumPy(band, bWrite, xoff, yoff, xsize, ysize, psArray, buf_type, resample_alg, callback, callback_data)
RuntimeError: /data/test_cases/usgs_test_cases/05130205_usgs/official_versions/hand_4_8_6_1/action/hlbk2_b0m_agreement.tif, band 1: Access window out of range in RasterIO(). Requested
(-6764,-1202) of size 267x184 on raster of 582x521.
Update: July 1, 2025
After some testing, the error is triggered when addressing a previous discovered issue related to gdal.UseExceptions().
When you run test_case_by_hydroid.py, it gives you the following warning:
/usr/lib/python3/dist-packages/osgeo/gdal.py:315: FutureWarning: Neither gdal.UseExceptions() nor gdal.DontUseExceptions() has been explicitly called. In GDAL 4.0, exceptions will be enabled by default.
warnings.warn(..
To fix this, I added a line to pixel_counter.py which is called by test_case_by_hydroid and ultimately threw the error. The attempted fix was to add gdal.UseExceptions()
to pixel_counter.py. We did a similar thing to getRasterInfoNative.py
as part of PR 1224. However, when applied here, it exposed some at least one HUC/benchmark that might have a legit problem that was being suppressed, 05130205_usgs. Might also exist in 12090301_ble. Could be a HUC output or a HUC/benchmark data file issue.
Other files that need the update are:
- pixel_counter.py (as mentioned above)
- create_vrt_file.py - and tested against a few places that use it
- create_ble_benchmark.py