I am trying to clip my Raster file according to a shapefile geometry. I am using the following code
gdalwarp -cutline INPUT.shp INPUT.tif OUTPUT.tif
But it is resulting a black color outside the shapefile geometry extent. I am giving the example here. In the first Image that I want to clip. The second image is the resultant raster but I want the 3rd Raster where the outside of the geometry will be null.
1st Image: INPUT Raster
2nd Image: OUTPUT Raster
3rd Image: I want to get output like this
Best Answer
You need to use the
-dstalpha
option togdalwarp
e.g.: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.