[Gdal-dev] GeoTiff and nodata values
Frank Warmerdam
warmerdam at pobox.com
Thu Nov 25 09:30:04 EST 2004
Kor de Jong wrote:
> Hi,
>
> I am writing some tests for the PCRaster raster driver and have a question
> about the nodata handling of the GeoTiff driver.
>
> For one test I read several kinds of PCRaster files using the GDAL PCRaster
> driver. Each dataset is written using CreateCopy and read again. This way I
> want to check that a written copy of a PCRaster file equals the original.
>
> When I use the PCRaster driver to create copies of the originals all goes
> well.
>
> Using the GeoTiff driver I noticed that for rasters in UINT1 (UInt8) and INT4
> (Int32) all goes well too, but for data in REAL4 (Float32) the missing value
> of the GeoTiff file is set to 0 instead of 1e-30 which is used by the
> PCRaster driver. The cell values of the original PCRaster file and the
> GeoTiff file do equal eachother, it is just that the nodata value of the
> GeoTiff file is not set to the value used in the PCRaster driver. In the
> other cases (UINT1, INT4), the nodata value is correctly copied into the
> GeoTiff.
>
> Does anyone know why the nodata value is handled differently by the GeoTiff
> driver, depending on the type of the cell values?
Kor,
I have committed a change to the GTiff driver that should fix this. The
nodata values for GTiff are ascii encoded and stored in a string tag. The
"%f" format was being used which does not permit exponents. So 1e-30 would
be internally rounded to zero. I have changed the format to %.16g which
I believe generally will preserve the precision of any double value.
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 | Geospatial Programmer for Rent
More information about the Gdal-dev
mailing list