I have an interpolated file which has positive Z values , so I want to use gdal_calc
to make them negative.
This works on the gdalcommand line with
gdal_calc -a interpolated.tif --outfile gdal_negative.tif --calc="-abs(-a)"
Based on this, I wanted to incorporate this into a python script so have done it with subprocess
as follows (please note that the interpolated tiff seen above is already stored in the variable interpolated_file
:
print('Pre calc')
negative_file = output_file + '_negative.tif'
calculation = '--calc=-abs(-a)'
subprocess.call(['gdal_calc.py', '-a', interpolated_file, '--outfile', negative_file, '--overwrite', calculation])
print('Post calc')
This runs ok, no errors thrown. HOWEVER, the result is the expected image for about 3/4 of it, and then the top of the raster extent is blank? Why is the top of the raster blank when there's data?! It's also the exact same command as the command line