I just bought some SPOT6/7 satellite imagery. This material has a 12bit format, however, the software I have to import it to just accepts 8, 16 or 32 bit files.
How can I convert my geoTIFF files to 16 bit without loosing the geo-ref.?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
You don’t have 12bit GeoTiffs, you have 16bit GeoTiffs that store data with values from 0-4095 (12bit range).
Anytime you need to change the format of a raster image
gdal_translate is the answer you are looking for. In this case it is simply
gdal_translate -ot Int16 src.tif dest.tif
There are plenty of other output types if your data is not an integer.
If you are looking to rescale the dynamic range from 12-bit to 16-bit, I would recommend using the scale parameter within gdal_translate:
gdal_translate -of GTiff -scale <min_val> <max_val> 0 65535 <src.tif> <dest.tif>
This will reassign the maximum value of your image to 65535 and your minimum value of your image to 0. This will stretch the image to the full 16-bit dynamic range, which may not be ideal for your application because it can overstretch the image. A pretty quick workaround is:
gdal_translate -of GTiff -scale <min_val> <max_val> 0 65535 -exponent 0.5 <src.tif> <dest.tif>
This will multiply all bands by x^0.5 after the values are scaled. This will produce a more realistic image with more realistic values while skewing the values closer to the full 16-bit dynamic range. This approach is commonly used in color correction of imagery when changing between radiometric resolutions, as it creates a more photo-realistic image.