[Gdal-dev] Do we need to specifically set band's min, max on writting?

Joaquim Luis jluis at ualg.pt
Tue Jun 12 22:26:28 EDT 2007


Frank Warmerdam wrote:
> Joaquim Luis wrote:
>> Hi,
>>
>> When saving a dataset to a file do we have to specifically say what 
>> are datasets min and max?
>> And if yes, how do we do that? I searched but didn't find any 
>> "GDALSetRasterMinimum"
>> I am using GDALRasterIO( hBand, GF_Write, ...) and thought band min, 
>> max were being
>> set automatically but a gdalinfo -stats shows this (the rest, as far 
>> as I can see, is ok)
>> ....
>> Band 1 Block=1781x1 Type=Float32, ColorInterp=Gray
>>  Minimum=-1.#IO, Maximum=-1.#IO, Mean=-1.#IO, StdDev=-1.#IO
>>  Metadata:
>>    STATISTICS_MINIMUM=-1.#IND
>>    STATISTICS_MAXIMUM=-1.#IND
>>    STATISTICS_MEAN=-1.#IND
>>    STATISTICS_STDDEV=-1.#IND
>
> Joaquim,
>
> You do not need to set raster min/max values yourself.  They are normally
> computed on request.  The above likely means you have some pixels - 
> perhaps
> unwritten portions - which have invalid floating point values.  This
> messes up the min/max calculations for floating point.

Frank,

After my post I found out that the cause was due to fact that the file 
(a geotiff DEM, e.g. a float) has NaNs.
That is on purpose, as they correspond to nodata values.
Do you mean that all files that have NaNs cannot have their min/max 
computed?

Joaquim



More information about the Gdal-dev mailing list