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

after an image has been georeferenced the transformation creates black edges. How could I set these to white instead of black using gdal?

would I have to somehow create a colour table and set nodata to white?



share|improve this question
up vote 4 down vote accepted

A nodata value is just that, no data. So the idea of having it white, black, or any other colour within the dataset doesn't make sense. Now, obviously when you load an image into a GIS, you have to represent nodata as something, and this is, in Quantum GIS at least, either whatever is underneath, or if there is nothing then the project's background colour. So there is a decoupling of what nodata means, how it is stored, and how it is represented.

If you're getting black regardless of the background colour of the GIS you're using, then the chances are GDAL hasn't set a nodata value at all, and it just defaults to black pixels. So you need to explicitly tell GDAL how you want nodata to be stored. With gdalwarp you use the -dstnodata command line switch to achieve this. You may find that nodata values in the source image aren't carried over in a warp operation, in which case you need to set it explicitly with -srcnodata. If you want to override an image's nodata vaue, you can do that with gdal_translate -a_nodata ....

share|improve this answer

Use GDAL's nearblack utility. It converts black, white or any specified color to black/white.

share|improve this answer

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.