[gdal-dev] alpha mask to data value

William Kyngesburye woklist at kyngchaos.com
Tue Apr 1 13:14:11 PDT 2014


I've wrestled with various nodata issues in the past, now it's hitting me again...

I'm using Photoshop to delete collars on scanned maps, creating an alpha mask.  GDAL has no problem with this.  What I want to do is merge maps together (after rectification), then set any remaining nodata areas to white, RGB 255,255,255.  Just dropping the extra alpha band doesn't work because nodata is set to 0,0,0, which is black.  The a_nodata option in gdal_translate just defines what existing value in the data is nodata.

I tried using gdalwarp with the -dstnodata option which should set nodata values in the output to a specific value, but it carries along the alpha band and ignores dstnodata.

  gdalwarp -dstnodata "255 255 255" in.tif out.tif
  Processing input file in.tif.
  Using band 4 of source image as alpha.
  Using band 4 of destination image as alpha.


-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

First Pogril: Why is life like sticking your head in a bucket filled with hyena offal?
Second Pogril: I don't know.  Why IS life like sticking your head in a bucket filled with hyena offal?
First Pogril: I don't know either.  Wretched, isn't it?

-HitchHiker's Guide to the Galaxy




More information about the gdal-dev mailing list