[gdal-dev] Fwd: NBITS=1 not preserved from vrt to tiff in multilayer tiff
From: Ritchie, Andrew<[hidden email]> Date: Thu, Jun 22, 2017 at 10:30 AM Subject: NBITS=1 not preserved from vrt to tiff in multilayer tiff To: [hidden email]
We are building TIFFs with fourteen layers, four of which are byte, and the remainder being binary. We are able to generate binary tiffs with NBITS=1 and stack them with gdalbuildvrt -separate, but when muiltilayer tiffs are created with gdal_translate or gdal_merge -separate, the NBITS metadata are ignored and the resulting tiff has the same bit depth (byte) for all fourteen layers.
Is there a way to force NBITS per band with a -co NBITS=1 option when using gdal_merge with the -separate flag? alternatively, is there a way to force gdal_translate to honor the NBITS of the source layers in a VRT?
U.S. Geological Survey
Pacific Coastal and Marine Science Center
2885 Mission St.
Santa Cruz, CA 95060 Office (831) 460-7454 Cell (360) 460-9453
However in the particular case you mention, multiple bands with different bit depth, there's nothing we can do. At least not easily.
In theory, the BitsPerSample tag could be used to record a different bit depth per band.
But the libtiff library used by GDAL (and lots of other software!) only support one single value (the first one). So basically the GeoTIFF writer looks at the parameter of the first input band and use them to create the TIFF file.
One potential format candidate would be the HFA / Erdas Imagine format. From a quick test, it doesn't look that multiple bit depth is supported on writing write now by the driver (but I think it supports that on reading). I think this is a limitation that could be relatively easily removed.