I am trying to read a large GeoTIFF file (18000×18000×40) of unsigned byte data format in R by raster
package. I hope to read it as raw
datatype (unsigned byte) in R, which then will be process by Rcpp
.
However, it seems that functions of raster
package only return the data as numeric
datatype (8-byte float) that will exceed the memory of my machine.
Are there any approach can read the GeoTIFF file and directly return the data as raw
datatype in R?
You could read the data in chunks. For example layer by layer, but you could also read the values by block (a subset of rows/columns, but all layers) depending on how you want the data organized for processing. Then for each chunk change the datatype. See terra::readValues
or the equivalent in "raster".
You can also have a look at vapour::vapour_read_raster
and vapour::vapour_read_raster_raw