Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've written a program in Python with GDAL bindings that generates a single band georeferenced GeoTIFF as output. From there I use the GDAL commandline tool gdaldem to colorize that image to highlight certain classes of pixels. I'd like to also lay it on top of a basemap DEM as final output but I need to do this procedurally in my program as opposed to load both layers into a GIS tool and blend from there.

Are there any GDAL command line utilities I can use to blend two GeoTIFFs together and output a pretty png?

Here's a specific example with some random datasets:

  DEM                                  Pixels

  Pixels + DEM Blended (This is what I want to do with command line tools)


I ended up using the blend function from PIL like this:

basemap_image ='basemap.png').convert('RGBA')
overlay_image ='overlay.png').convert('RGBA')
combined = Image.blend(basemap_image, overlay_image, 0.8)"out.png")
share|improve this question
up vote 1 down vote accepted

You're going to want to use the Python imaging library. PIL.

You will want to load up the first image of the DEM and make sure its in an RGBA format.

from PIL import Image

dem_image ='dem.png').convert('RGBA')
color_pixels ='pixels.png').convert('RGBA')

combined = dem_image.paste(color_pixels, (0,0), color_pixels)

Might need to make sure your color_pixels image has an alpha layer as that's what is used for paste. Otherwise you will have to go through it and create a transparency layer in color_pixels by iterating over the values and setting white to an alpha channel.

Hope that helps, or at least gets you started.

share|improve this answer
Yep, this is great! Thanks for the help. – Rich Mar 27 '12 at 5:52
FYI, the blend function turned out to be the most helpful for what I was trying to do. – Rich Mar 29 '12 at 6:27

Sorry, I'm not a GDAL expert but this can help you:

GDAL have commands to merge, wrap, ... and many more things to do with geo-images.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.