gdalwarp cutline along with shapefile

You need to use the -dstalpha option to gdalwarp e.g.:

gdalwarp -cutline INPUT.shp -crop_to_cutline -dstalpha INPUT.tif OUTPUT.tif

This will add an alpha band to the output tiff which masks out the area falling outside the cutline.

A late answer, but hopefully it will help someone else with the same problem.


Try to specify the nodata-value from your input raster and set it for the output as well. Furthermore add the option -crop_to_cutline to make exact crops. More about the options here.

gdalwarp -srcnodata <in> -dstnodata <out> -crop_to_cutline -cutline INPUT.shp INPUT.tif OUTPUT.tif

You can use raster clip option in QGIS which runs gdalwarp in the background and configures the right options for you.

http://www.qgistutorials.com/en/docs/raster_mosaicing_and_clipping.html

Tags:

Gdal

Gdalwarp