[Gdal-dev] remove background from a geotiff

Matt Wilkie matt.wilkie at gov.yk.ca
Thu Apr 26 18:22:33 EDT 2007


John Cartwright wrote:
> Thanks for your reply Matt.  I did take a look at nearblack, but in my 
> case I already have a consistent color in the background and was looking 
> to make that color transparent.  It didn't look to me as if nearblack 
> would help me in this situation.  However, I realized that I could use 
> imagemagick to handle the conversion.

It's nice to have more than one path to get to one's goal. You take the 
one you can see from where you are!

For future reference, there is a wholly gdal solution albeit multi-step 
First use nearblack to get consistent colour (which you already had), 
then use gdalwarp to choose which values to make nodata (transparent), 
then gdal_translate to desired out format (warp doesn't support the same 
number of write formats):

  gdalwarp -srcnodata 0,0,0 -dstalpha crm_east.tif crm_east_alpha.tif
  gdal_translate -of png crm_east_alpha.tif crm_east.png


cheers,

-- 
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
http://environmentyukon.gov.yk.ca/geomatics/
--------------------------------------------




More information about the Gdal-dev mailing list