I have a raster file (.tif) that contains integer values from 1 to 31. I have realized that the values are stored as Float32
with NoData Value=-3.39999999999999996e+38
(see raster information below). I think that the optimal method to store the data is as unsigned 8 bit integer (QGIS Byte
) as there are no decimal values and the maximum value is below 255. I have used the Translate (convert format)
tool available from GDAL
to change the data type from Float32
to Byte
(following these instructions). However, I have run into two issues:
- The resulting file is BIGGER than my original file (from 31MB to 268MB). I noticed that the original file had
COMPRESSION=LZW
and tried to use various compression formats underProfile
(i.e.default
,no compression
,Low compression
,High compress
,JPEG compression
) but I was not successful in reducing file size while maintaining data quality (e.g. usingJPEG
with 100 resulted in some values being +/-1 of the values they should be and some random additional pixels) - I had difficulty setting the
NoData
value. It seems that0
worked in my case but I may have files with 0-values that are meaningful and I wouldn't know how to convert the multidecimal NoData value from the Float to an integer value that is not confused with actual zero values in the dataset.
Metadata of original file
Size is 21768, 12920
Pixel Size = (250.000000000000000,-250.000000000000000)
Image Structure Metadata:
COMPRESSION=LZW
NoData Value=-3.39999999999999996e+38
UPDATE: According to this related post, the raster size is computed based on the following formula:
The size of a raster is just the product of bit-depth/8, bands, rows, and columns plus header metadata (statistics, etc.)
32/8* 1* 21768* 12920* =1124970240 Bytes/(1024*1024) ~1072MB
8/8* 1* 21768* 12920* =281242560 Bytes/(1024*1024) ~268MB
That gives me the size Windows indicates for my 8-bit raster without compression.
These are the options in the dialog box: