0

I tried to do raster calculation and save the file to a new raster with subprocess in Python:

subprocess.run(['python', 'gdal_calc.py', '-A', image1, '-B', 'MSL_TEMP.tif', '--outfile = DEMNAS_MSL.tif', '--calc = A - B' ])

and comes with this error:

TypeError: expected str, bytes or os.PathLike object, not DatasetReader

Would you please give me the solution?

0

1 Answer 1

0

It can be run with this code:

subprocess.run(['python', 'gdal_calc.py', '-A', input1, '-B', input3, '--outfile=demnas_msl.tif', '--calc=A - B' ])

with input1 and input3 are string of input images. However, the result came in returncode =2

CompletedProcess(args=['python', 'gdal_calc.py', '-A', 'DEMNAS_KARIMUNJAWA.tif', '-B', 'msl_temp.tif', '--outfile=demnas_msl.tif', '--calc=A - B'], returncode=2) 

Your Answer

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

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