1

I am trying to use GDAL Python API to deal with some big raster, and when I read these rasters into Python, I get warnings like that:

Warning 1: TIFFFetchNormalTag:ASCII value for tag "GeoASCIIParams" contains null byte in value; value incorrectly truncated during reading due to implementation limitations
Warning 1: TIFFReadDirectory:Sum of Photometric type-related color channels and ExtraSamples doesn't match SamplesPerPixel. Defining non-color channels as ExtraSamples.
Warning 1: TIFFFetchNormalTag:ASCII value for tag "GeoASCIIParams" contains null byte in value; value incorrectly truncated during reading due to implementation limitations
Warning 1: TIFFReadDirectory:Sum of Photometric type-related color channels and ExtraSamples doesn't match SamplesPerPixel. Defining non-color channels as ExtraSamples.

Do anybody encounter problems like this? Why did this thing happen?

The raster I use is about 2.2G for one raster, and the raster' format is TIFF.the warnings don't affect the later use of the data, it is still an annoying issue, I want to know how to fix this.

2

You can suppress the warnings (as long as you're sure there's no real issue with your data) with gdal.PushErrorHandler('CPLQuietErrorHandler'). If you do this any errors will also not get printed, so make sure you tell GDAL to raise a Python exception when an error occurs with gdal.UseExceptions().

E.g.

# Stop GDAL printing both warnings and errors to STDERR
gdal.PushErrorHandler('CPLQuietErrorHandler')

# Make GDAL raise python exceptions for errors (warnings won't raise an exception)
gdal.UseExceptions()
  • Thanks for your contribution, it worked very well – Zhou XF Aug 20 at 1:27
2

The first warning means that the value of GeoASCIIParams tag is not read as it was written because the original image is having NULL character in the value of the tag. NULL can be used as a delimiter between strings http://freeimage.sourceforge.net/fnet/html/A633E9A9.htm but obviously GDAL takes just the first string.

The second error means that the writer that created the TIFF file has written the metadata wrong. Perhaps the metadata tells that image is of RGB type without extra samples (bands) but actually the image has four bands and GDAL considers it as RGBA. By doing that GDAL at least doesn not drop a band but it may make a wrong guess about the role of the extra band which is not necessarily alpha but could contain data as well (for example RGB+Near Infrared).

  • I am not familiar with C++, so what effect will it be if GDAL just takes the first string? It seems that this warning does not affect anything for now.@user30184 – Zhou XF Aug 19 at 8:06
  • I believe it does not make any harm at all but it would be nice to see the value of the tag GeoASCIIParams. Can you check the tag or share the original image? – user30184 Aug 19 at 8:24
  • I could share the original image,it is the sentinel-2 image and I converted it into TIFF, how could I share the image to you?@user30184 – Zhou XF Aug 19 at 8:45
  • Could you first try if the listgeo program could show the contents of GeoASCIIParams? – user30184 Aug 19 at 10:14
  • Perhaps a better utility to use is tiffdump. Usage: tiffdump -m 1000 image.tif >dumped_tags.txt. – user30184 Aug 19 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.