Tuesday, 7 March 2017

python - Convert specific RGB (GeoTIFF) color to transparent


I have an RGB GeoTIFF file and I want to convert a specific RGB colour to transparent. I would like to use GDAL for doing this, but external Python scripts are also an option (though I haven't learned the art of Python scripting yet).


My thoughts are:



  1. Add a 4th band to my GeoTIFF file and fill with 255.

  2. Insert 0 into the 4th band where RGB colour == target colour


The first part I think I can solve using


gdalwarp -dstalpha source.tif target.tif


The second though I don't know how to solve. matt wilkie suggest using a Python script he wrote, but I think that is done separately for each band and not for a specific colour.


How can I assign a value to the 4th band of my TIFF when the RGB colour is equal to a specific RGB colour?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...