0

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

asked May 30, 2014 at 7:03

1 Answer 1

1

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"'])
answered May 30, 2014 at 7:34
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.