[gdal-dev] Need help generating output with alpha channels using Python API

Michal Migurski mike at stamen.com
Mon Mar 14 12:50:16 EDT 2011


Hello,

I'm having some difficulties understanding how to get GDAL to generate images with usable alpha channels. I have 3-channel RGB input JPEG image, delivered to GDAL as a VRT with a projection and ground control points, which I'm warping to an output that's no longer rectangular, leaving background areas exposed. Here is an example output:

	http://things.teczno.com/gnomotile.png

The black parts are intended to be transparent, but I haven't been able to understand how to make that work. Here's the relevant part of my Python code:

	http://dpaste.com/hold/500308/

I've tried to switch to a four channel output which gets me what I think are CMYK channels. I've tried to use SetNoDataValue on the destination bands to make the background purple so it can be easily knocked out. I've tried to create the GTiff output dataset using the ALPHA=YES creation option, but it seemingly doesn't make a difference. None of these ideas has worked - does anyone have any ideas on how the Python API can be used to create transparent output?

-mike.

----------------------------------------------------------------
michal migurski- mike at stamen.com
                 415.558.1610





More information about the gdal-dev mailing list