If ref_img is smaller than the mon_img in either X or Y, line 255 in matcher.py fails to read any data, as x_off+x_size and y_off+y_size exceed the raster bounds:
but an ideal solution might be to read the maximum area from each raster, if the tiles can be of different sizes.
Separately, I note that Python exceptions are not enabled in GDAL (by calling gdal.UseExceptions()), and the code does not explicitly check that GDAL calls succeeded. This is what leads to the ref_img.read call failing silently, and the unhelpful exception being raised later. GDAL is already emitting log warnings about this, and best practice would be to enable exceptions.
If
ref_img
is smaller than themon_img
in either X or Y, line 255 inmatcher.py
fails to read any data, as x_off+x_size and y_off+y_size exceed the raster bounds:ref_box
is returned as None, and an exception is raised on line 234, because this is an invalid operation onNone
:The documentation never states that
ref_img
must be larger.If this is a bug, a quick fix would be to modify the
x_size
andy_size
calculations to always refer to only the valid area across both rasters:but an ideal solution might be to read the maximum area from each raster, if the tiles can be of different sizes.
Separately, I note that Python exceptions are not enabled in GDAL (by calling
gdal.UseExceptions()
), and the code does not explicitly check that GDAL calls succeeded. This is what leads to theref_img.read
call failing silently, and the unhelpful exception being raised later. GDAL is already emitting log warnings about this, and best practice would be to enable exceptions.