[gdal-dev] Re: help needed with image creation

WolfgangZ wollez at gmx.net
Wed Feb 6 07:58:38 EST 2008


Frank Warmerdam schrieb:
> Wolfgang wrote:
>> 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.
> 
> Wolfgang,
> 
> You can't generally assign a palette to floating point geotiff files.
> There is no way for applications to understand how to apply it.
> 
> Generally speaking, in GeoTIFF, you either offer the raw floating point
> science data, or you offer a version of it is that been prescaled to
> integers (usually 0 to 255) with a colormap.
> 
> I'd add that it is very common for folks to distribute raw science
> data in floating point, and for the decision on a colormap to be
> applied being made by the user in the viewing application.
> 
> Best regards,

Frank,
thanks for your answer! I recalculate the floats to a color manually, I 
just thought that there would be somewhere a convenience function to do 
that.
Many thanks
Wolfgang



More information about the gdal-dev mailing list