Opened 8 years ago
Closed 8 years ago
#6492 closed defect (fixed)
gdal_calc refuses bands named -L : -Z
Reported by: | pprosp | Owned by: | warmerdam |
---|---|---|---|
Priority: | high | Milestone: | 2.2.0 |
Component: | Algorithms | Version: | unspecified |
Severity: | blocker | Keywords: | gdal_calc |
Cc: |
Description
I'm on windows 7 64-bit with QGIS Essen, but working on the OSGEO4W shell. gdal_calc will only accept the first nine input rasters (named from -A to -I) and create an output file but throwing a python error (popup window).
Any additional raster added to the list and indicated as -L to -Z incurs in a further error with no output file produced.
Input rasters have all the same number of bands (7), dimension, location and projection. There is no problem with files -L, -M and -N in their own (they behave normally when they're the first ones in the list and referred to as -A, -B and -C).
This is the full command with nine bands and outcome (case successful):
C:\>gdal_calc -A E:\001\h00v08.tif --A_band 2 -B E:\032\h00v08.tif -C E:\061\h00v08.tif -D E:\092\h00v08.tif -E E:\122\h00v08.tif -F E:\153\h00v08.tif -G E:\183\h00v08.tif -H E:\214\h00v08.tif -I E:\245\h00v08.tif --calc="A+B+C+D+E+F+G+H+I" --overwrite --outfile E:\h00v08.tif --debug gdal_calc.py starting calculation A+B+C+D+E+F+G+H+I file A: E:\001\h00v08.tif, dimensions: 2400, 2400, type: Byte file B: E:\032\h00v08.tif, dimensions: 2400, 2400, type: Byte file C: E:\061\h00v08.tif, dimensions: 2400, 2400, type: Byte file D: E:\092\h00v08.tif, dimensions: 2400, 2400, type: Byte file E: E:\122\h00v08.tif, dimensions: 2400, 2400, type: Byte file F: E:\153\h00v08.tif, dimensions: 2400, 2400, type: Byte file G: E:\183\h00v08.tif, dimensions: 2400, 2400, type: Byte file H: E:\214\h00v08.tif, dimensions: 2400, 2400, type: Byte file I: E:\245\h00v08.tif, dimensions: 2400, 2400, type: Byte Generating output file E:\h00v08.tif output file: E:\h00v08.tif, dimensions: 2400, 2400, type: Byte using blocksize 2400 x 1 0 .. 10 .. 20 .. 30 .. 40 .. 50 .. 60 .. 70 .. 80 .. 90 .. 100 - Done
###################
With ten or more rasters (case UNsuccessful):
C:\>gdal_calc -A E:\001\h00v08.tif --A_band 2 -B E:\032\h00v08.tif -C E:\061\h00v08.tif -D E:\092\h00v08.tif -E E:\122\h00v08.tif -F E:\153\h00v08.tif -G E:\183\h00v08.tif -H E:\214\h00v08.tif -I E:\245\h00v08.tif -L E:\275\h00v08.tif --calc="A+B+C+D+E+F+G+H+I+L" --overwrite --outfile E:\h00v08.tif --debug gdal_calc.py starting calculation A+B+C+D+E+F+G+H+I+L file A: E:\001\h00v08.tif, dimensions: 2400, 2400, type: Byte file B: E:\032\h00v08.tif, dimensions: 2400, 2400, type: Byte file C: E:\061\h00v08.tif, dimensions: 2400, 2400, type: Byte file D: E:\092\h00v08.tif, dimensions: 2400, 2400, type: Byte file E: E:\122\h00v08.tif, dimensions: 2400, 2400, type: Byte file F: E:\153\h00v08.tif, dimensions: 2400, 2400, type: Byte file G: E:\183\h00v08.tif, dimensions: 2400, 2400, type: Byte file H: E:\214\h00v08.tif, dimensions: 2400, 2400, type: Byte file I: E:\245\h00v08.tif, dimensions: 2400, 2400, type: Byte file L: E:\275\h00v08.tif, dimensions: 2400, 2400, type: Byte Traceback (most recent call last):
File "C:\PROGRA~1\QGISES~1\bin\gdal_calc.py", line 326, in <module>
main()
File "C:\PROGRA~1\QGISES~1\bin\gdal_calc.py", line 323, in main
doit(opts, args)
File "C:\PROGRA~1\QGISES~1\bin\gdal_calc.py", line 93, in doit
myDataType.append(gdal.GetDataTypeName(myFiles[i].GetRasterBand(myBands[i]).
DataType)) IndexError: list index out of range
Change History (1)
comment:1 by , 8 years ago
Milestone: | → 2.2.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
You must use consecutive letters, without hole. So A,B,C,D,E,F,G,H,I,J. I see this limitation has been removed in the latest version of the script in trunk : https://svn.osgeo.org/gdal/trunk/gdal/swig/python/scripts/gdal_calc.py . You can likely use it as a replacement of the version you have.