Take the 2-minute tour ×

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

2 Answers 2

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


