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
Answer
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.
No comments:
Post a Comment