[R-sig-Geo] WriteRaster as Float
diamant zebrat
diamant.zebrat at gmail.com
Tue Nov 11 10:12:33 CET 2014
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>:
> Zebrat--
> Without example code it is difficult to guess what you tried, and what you
> desire. By "float" do you mean FLT4S 4-byte values? If so, try
> datatype='FLT4S' in your call to writeRaster(), which should be the same as
> 'Float32' in gdal. If you mean something else, I guessed wrong, so you
> might specify a bit more about what you have, want, and have tried.
>
> Tom 2
>
> On Mon, Nov 10, 2014 at 4:38 AM, diamant zebrat <diamant.zebrat at gmail.com>
> wrote:
>
>> Hello,
>> I am working with R processing Meteosat imagery, which mean a lot of
>> images
>> every day, and thus a lot of available storage space
>> It looks like the write raster function of the raster package only allows
>> to write a Geotiff as integer or as double. I only need float precision,
>> so
>> I don't need a double as the resulting file gets too big. Is there any way
>> to store a geotiff with float precision?
>> Thank you
>> Zebrat
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list