Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to clip my Raster file according to a shape file geometry. I am using the following code

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

But it is resulting a black color outside the shape file 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

1st Image: INPUT Raster

2nd Image: OUTPUT Raster

2nd Image: OUTPUT Raster

enter image description here

3rd Image: I want to get output like this

share|improve this question
up vote 11 down vote accepted

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.

share|improve this answer
without the -srcnodata <in> -dstnodata <out> hint by Curlew it did not work for me. – Jens Jun 4 '14 at 19:33

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
share|improve this answer
Can You elaborate little bit more? What is used as <in> and <out> ? – Devils Dream Jan 2 '13 at 19:02
<in> is your input rasters nodata-value and <out> for your output-raster. Please have a look at the provided link where you can find all information and options (output format, source, extent, ... ) – Curlew Jan 2 '13 at 23:15

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

share|improve this answer
I want a ***.tif format – Devils Dream Jan 2 '13 at 19:18
The steps outlined in the link above should give you a .tif output. – spatialthoughts Jan 2 '13 at 20:01

protected by Aaron Nov 26 '14 at 12:40

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.