[gdal-dev] gdal_merge and the treatment of nodata value

Matt Wilkie matt.wilkie at gov.yk.ca
Wed Sep 3 12:40:44 EDT 2008

Hi Andreas,

If you use gdalwarp rather than gdal_merge you could use the -srcnodata 
and -dstnodata flags to change the null value:

   gdalwarp in-01.tif in-02.tif outimage.tif -srcnodata 0 -dstnodata 255

This assumes the nodata in all the input images are the identical (0, or 

Since these are scanned maps, the edges may not be pure white or black, 
in which case you may need to pre-process with the nearblack utility: 


matt wilkie
Geographic Information,
Information Management and Technology,
Yukon Department of Environment
10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
867-667-8133 Tel * 867-393-7003 Fax

Andreas Neumann wrote:
> Hi,
> I am using gdal_merge to merge different rasters. The problem is that the
> nodata values appear as black and I want to have them white.
> Is there an option to set nodata values to white with gdal_merge? Or would
> I have to do this as a postprocessing?
> The problem is that the images are too large to be opened in an
> interactive application like Photoshop and Gimp. Otherwise I would correct
> it in there.
> Thanks for an idea on how to add nodata as white to my gdal_merge workflow.
> Andreas

More information about the gdal-dev mailing list