Any recommendations you have are appreciated.
Thank you.
# Integer matrix with 24-bits -------
x <- matrix(sample(1:16777216, size= 21269*25590, replace = TRUE), nrow = 21269, ncol = 25590)
print(object.size(x),units="Mb")
rm(x)
# 2076.2 Mb
# Float/decimal -------
x <- matrix(rnorm(21269*25590), nrow = 21269, ncol=25590)
print(object.size(x),units="Mb")
rm(x)
# 4152.5 Mb
library(raster)
ndvi <- raster("C:/MyFiles/my_ndvi.tif") # <-- Point the raster function to your own NDVI layer
print(object.size(values(ndvi)), units = "Mb") # Check data size / comment this line if it throws an out-of-memory error
# Convert data as integer: INT2S = [-32767, 32767]
ndviInt <- round(ndvi * 10000)
# Write a new NDVI raster file as integer type
writeRaster(ndviInt, "C:/MyFiles/ndviInt.tif", datatype="INT2S") # <-- Change the output path here
# Reload the data now as integer
ndviInt <- raster("C:/MyFiles/ndviInt.tif") # <-- Change the inpput path here to the new ndvi raster file
print(object.size(values(ndviInt)), units = "Mb") # Check new size / comment this line if it throws an out-of-memory error