4

Am importing a RGB TIFF into QGIS 3.4 and when I zoom in I can see the image properly, however, when I zoom out the layer turns black (most of it) and red (a small portion). After doing some search I found this, which suggests that this problem is caused by issues with pyramids and statistics with the layer. There is some support there but that is for ArcGIS. I tried building the pyramids in QGIS Raster-->Miscellaneous-->Build Overviews (Pyramids) (I have done it in the past for .asc files), but got the following error

ERROR 1: TIFFAppendToStrip:Maximum TIFF file size exceeded. Use BIGTIFF=YES creation option.
ERROR 1: An error occurred while writing a dirty block from GDALRasterBand::RasterIO

Does anyone know how I could to build pyramids for a TIFF in QGIS?

If so, what "Overview levels" should I select?

Or does anyone know how to solve this issue for my RGB TIFF?

  • 2
    Can you use command line? If so use GDALAddO gdal.org/gdaladdo.html first with -clean to get rid of existing pyramids then use the same command with -ro so as not to internalize the pyramids. Depending on the size of your raster levels should be 4 8 16 32 64 but if very large add 128 256 to the levels. The problem comes from your GeoTIFF not being a large GeoTIFF and you're exceeding the 4GiB limit by internalizing your pyramids, specifying -ro will force GDALAddO to write the overviews to a separate file, thus not increasing your existing file size. – Michael Stimson Jan 16 at 3:33
  • @Michael Stimson, I think your comment is worthy of posting as an answer! – Ben W Jan 16 at 3:41
5

This error is because you're building pyramids internally (default) on a GeoTIFF file which is not a big TIFF. The pyramids are being appended to the existing file which makes the resultant file exceed the 4 GiB limit. This is evident by the error message Maximum TIFF file size exceeded.

From here you have some options, the error message indicates using BIGTIFF=YES which you can do from QGIS with Raster::Translate, writing a new file which can exceed the 4 GiB limit, for example this post describes the process.

Or if you're comfortable with the CMD tools you can attempt repair the existing TIFF file in a two step process:

  1. Remove the existing bad pyramids with GDALAddO -clean option. It is important to remove the existing internal pyramids before creating new external pyramids as this would create a conflict of which pyramids to use; I would think that the internal pyramids would take precedence but that's an assumption - I haven't tried this to prove which takes precedence.
  2. Create new external pyramids with GDALAddO -ro option which will force the creation of an OVR or RRD (–config USE_RRD YES) file to contain the pyramids. For most rasters levels of 4 8 16 32 64 (5 levels of pyramid) is sufficient but if your file is especially large use 4 8 16 32 64 128 256 to create 7 levels.

This may not work if the file is already too broken to fix, if this is the case your only option is to translate the file to a new raster.

  • Thanks a lot for this, I managed to solve the issue in both ways, by using a bigTiff but also using the command line. Thanks! – Juan Ossa Jan 21 at 6:59

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.