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
Answer
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"'])
No comments:
Post a Comment