[gdal-dev] help needed with image creation

Wolfgang wollez at gmx.net
Mon Feb 4 15:02:22 EST 2008


Hi,

I want to create some images where I set the pixel values manually. The 
values are Floats that need to be mapped finally to a color map. I'm not 
really a skilled programmer but I've managed to get a first idea how to 
do it (in python):

from osgeo import gdal
import numpy as Numeric

format = "GTiff"
driver = gdal.GetDriverByName( format )

dst_filename='test.tif'
dst_ds = driver.Create( dst_filename, 3, 2, 1, gdal.GDT_Float32 )
raster=Numeric.array([[ 1.,  200.5 ,  3. ],[ 256. ,  5. ,  60. ]])
dst_ds.GetRasterBand(1).WriteArray( raster )

What I don't understand is how to create/define a color map so that the 
result looks better? I also suppose that it is not the best to create 
float tiffs as not so many applications will support that type. It would 
help me much if anybody could show me the steps needed to do the task.

I'm sorry if this looks too easy for skilled programmers, but I'm 
completely new to program graphics (with GDAL) and I still don't have 
the overview over all GDAL functions.

Any help is appreciated.

Wolfgang


More information about the gdal-dev mailing list