I'm trying to clip an image in gdal and when I run this code:
gdalwarp -cutline path/to/polygon.shp \
-crop_to_cutline -dstnodata "-9999.0" \
in_raster.tif \
out_raster.tif
it runs ok and output is working ok too. However, when running this code:
import ogr
import subprocess
inraster = 'in_raster.tif'
inshape = 'polygon.shp'
outraster = 'out_raster.tif'
subprocess.call(['gdalwarp', '-cutline', inshape, '-crop_to_cutline', '-dstnodata -9999.0', inraster, outraster])
it doesn't create any output. I reckon there is something wrong in -dstnodata <nodata_value>
.