[gdal-dev] Creating multi-band TIFF from a single band

Frank Warmerdam warmerdam at pobox.com
Tue Mar 25 15:20:09 EDT 2008


Gregor Mosheh wrote:
> Hey, all. What tool would I use for this; is this something more for 
> libtiff or ImageMagick than for GDAL? I could do it pixel-by-pixel in 
> Python Imaging Library or PHP+GD, but I have a feeling that it would be 
> incredibly slow and that a faster way exists.
> 
> I have:
> TIFF with data values encoded as pixel values, e.g. pixel value minus 20 
> then times 10 equals feet elevation.
> 
> I want a set of TIFFs:
> 
> a) A TIFF with the values translated to true values, so the pixel value 
> is true feet. It is my understanding that a TIFF can have 
> signed-24-bit-float pixel values, which would be just peachy for both 
> range and accuracy. (not all cases are as trivial as the one above)
> 
> b) Colorized TIFFs based on the numeric ranges in the true-value TIFF, 
> using multiple prefab palettes. If I have to run multiple commands, one 
> per palette, that's OK.
> 
> c) In both cases, retaining the georeferencing as these are for use in 
> maps.

Gregor,

I would suggest implementing such operations using GDAL's Python bindings
and numeric python to do the array operations.  The following scripts might
prove to be useful examples:

   http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/val_repl.py
   http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/rel.py
   http://svn.osgeo.org/gdal/trunk/gdal/swig/python/scripts/pct2rgb.py

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list