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 having some trouble getting gdalwarp to work. I want to clip my input raster in.img to the boundary of a polygon stored in a shapefile polygon.shp and save it out as out.img. The data type of in.img is 32-bit float. The raster cells external to the polygon delineation have a value of 0.0. I figure gdalwarp ought to be able to clip in.img to my polygon boundary, effectively setting the external 0.0 values to NoData (that is what I want to do, anyway). I am using the following command at the Windows command prompt:

gdalwarp -of HFA -cutline polygon.shp in.img out.img

The problem is, this doesn't seem to achieve anything. out.img is essentially a copy of in.img in that the cells external to the polygon boundary are still 0.0—my understanding was that this would only happen if I used the -crop_to_cutline flag.

What am I doing wrong?

share|improve this question
up vote 1 down vote accepted

It seems to work when I include -dstnodata -3.40282346639e+038. Go figure. I'm not sure why it couldn't work this out by itself.

share|improve this answer
You might want to accept your answer. I think GDAL is working as it should. It doesn't make assumptions about what you would want with the nodata values. Different people use it after all and those people have different ways of doing things. The -dstnodata switch is a compromise in that direction. And this is a command line tool, not a full GUI package. – R.K. Sep 22 '12 at 6:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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