I'm having some trouble getting gdal_calculations to work reliably with some
inputs that I think should be working properly. It works great on occasion, but
usually I get an error like:
RuntimeError: Invalid dataset dimensions : 498 x -435
Using those same two inputs in the raster calculator in QGIS with the same
formula, it produces the expected output.
Command I'm running:
/usr/bin/python -m gdal_calculations --A /tmp/rastercalc7LCtaE.tif --B
/tmp/rastercalc9lrqbS.tif --extent MAXOF --reproject --outfile
/tmp/rastercalcZRb4Dh.tif --calc='(A[0] * B[0])'
I've attached the two files. They overlap nicely in QGIS, where the calculation
works as expected. If it matters, I'm using GDAL 1.11.0 with Python 2.7.3.
Can you provide any guidance? Am I using it incorrectly, or is this a bug of
some kind?
I'd like to use this as part of an automated process (hence the weird
filenames), so having it highly reliable would be important to me. If it helps,
I could provide a limited amount of funding for the support/consulting on this
issue. Probably not a ton, but enough for a nice dinner or two at least!
You can reach me directly at chris (at) strategiccode.com if needed.
Thank you!
Chris Michaelis
PS. More output, if useful:
Python 2.7.3 (default, Feb 27 2014, 20:00:17)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import osgeo.gdal
>>> print osgeo.gdal.__version__
1.11.0
>>>
/usr/bin/python -m gdal_calculations --A /tmp/rastercalc7LCtaE.tif --B
/tmp/rastercalc9lrqbS.tif --extent MAXOF --reproject --outfile
/tmp/rastercalcZRb4Dh.tif --calc='(A[0] * B[0])' 2>&1
Running calculation
0Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/gdal_calculations/__main__.py", line 25, in <module>
gdal_calculations.gdal_calculate.main()
File "/usr/local/lib/python2.7/dist-packages/gdal_calculations/gdal_calculate.py", line 235, in main
outfile = eval(args.calc)
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/gdal_calculations/gdal_dataset.py", line 397, in __mul__
return self.__operation__(operator.__mul__,other)
File "/usr/local/lib/python2.7/dist-packages/gdal_calculations/gdal_dataset.py", line 338, in __operation__
dataset1,dataset2=self.check_extent(other)
File "/usr/local/lib/python2.7/dist-packages/gdal_calculations/gdal_dataset.py", line 80, in apply_environment
dataset1,dataset2=self.__check_extent__(dataset1,dataset2)
File "/usr/local/lib/python2.7/dist-packages/gdal_calculations/gdal_dataset.py", line 184, in __check_extent__
if dataset1.extent!=ext: dataset1=ClippedDataset(dataset1,ext)
File "/usr/local/lib/python2.7/dist-packages/gdal_calculations/gdal_dataset.py", line 713, in __init__
self._dataset=gdal.Open(self._filename)
RuntimeError: Invalid dataset dimensions : 498 x -435