The following code works when used with cmd prompt:

C:\gdal_calc.py -A C:\a.tif --outfile=C:\result.tif --calc="A+1"

When I want to run the same code with subprocess:

import subprocess

subprocess.call(['C:\\gdal_calc.py', '-A', 'C:\\a.tif', '--outfile=C:\\result.tif', '--calc="A+1"'])

The following error results:

[Error 193] %1 is not a valid Win32 application

Please help me. I am highly frustating with it. This problem is basically the syntax error when the parameters are fed up into subprocess.call method what I think.

Here is the reference: http://www.gdal.org/gdal_calc.html

gdal_calc.py file is here: http://svn.osgeo.org/gdal/trunk/gdal/swig/python/scripts/gdal_calc.py


The gdal_calc.py script isn't an executable. Try calling python gdal_calc.py etc...

subprocess.call([sys.executable, 'C:\\gdal_calc.py', '-A', 'C:\\a.tif', '--outfile=C:\\result.tif', '--calc="A+1"'])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.