i try to use python GDAL raster calculation to take some raster result where i need.
i windows user and i work in OSGeo4W Shell.
first i try to work using batch file with success.
code work with batch file :
import os
os.system("C:/xxx/xxx/path/test.bat ")
batch file :
gdal_calc.py -A C:/xxx/xxx/path/a_layer.tif -B C:/xxx/xxx/path/a_layer.tif --outfile=C:/xxx/xxx/path/a_layer.tif --calc="(2*A)+(2*B)"
all work without error.
but if i try to wotk using python then any time before complete my script then python.exe
crashed.any time
try using python script :
call('python C:/OSGeo4W64/bin/gdal_calc.py -A {0} -B {1} -C {2} --outfile={3} --calc="(2*A)+(2*B)"'.format(a_layer,b_layer,out_layer))
i want to use python script because i have many options for working usnig python and gdal.
but can someone to tell me why batch file work and not python script ?
edit
if print 'PATHEXT'
environment variable in OSGeo4W Shell i dont have '.PY'
extesion.but if is this hte problem can i define 'PATHEXT'
inside some python script ?
stop working python.exe
.can you show me some example using subprocess.Popen ?osgeo.gdal
and NumPy; see the example forCreateCopy()
to get an idea how to do this in a more Python way