Skip to content
Prev 21969 / 29559 Next

WriteRaster as Float

Tom, here goes the details
The Meteosat images are composed by a matrix of pixels with values of
surface temperature (or cloud top temperature) in Kelvin, which means
values like 273.15
I wanted to keep the decimals, thus I need a FLT4S 4-byte values. When using
writeRaster(TTemp,filename=nom,format="GTiff",overwrite=T,datatype="FLT4S")
I get a file with a size of 7.495.158 bytes.  My particular image is a
matrix of 1201 lines x 803 columns = 964.403 pixels,
with this option (datatype="FLT4S") it looks like we get an image that uses
8 bytes to store each pixel. In fact, we only need 4 bytes (float) to store
values like 273.15, thus I am getting images which are too big. Keep in
mind there is a Meteosat image each 15 min -> 96 a day, etc. These means a
lot of storage space and I should care about it
When opening one of these GEOTIFF (LTS4S) with a GIS package, it get an
image that is "double precision", confirming that the writeRaster is using
8 bytes to store each pixel when creating the GEOTIFF with the
datatype="FLT4S" option
The conclusion is that the writeRaster routine is not optimized to use the
minimum space when writing a geotiff
The only alternative by now is to multiply my kelvins by ten and save it as
an integer, this way I only keep one decimal but I get small size files
writeRaster(TTemp,filename=nom,format="GTiff",overwrite=T,datatype="INT1U")
However, I still want to keep the real values using 4 byte for each pixel...
thank you
Zebrat

2014-11-11 4:32 GMT+00:00 Tom Philippi <tephilippi at gmail.com>: