[GIS] Raster Calculator Error : Insufficient memory available for operation

qgisraster-calculator

Performing Raster calculator with a raster of size about 750 mb and it is showing an error of insufficient memory .
Ram : 8 GB
I have a huge space available at the location where it has to be saved.

Basically input raster is for 250 m NDVI in hdf format. I converted this hdf format to tif and then merged all tif to one merged file with GDAL. now when I am applying raster calculator on this input , it shows the error for insufficient memory.
Input raster Size is about : 750 MB.
compression is not done.

Output format needed is tif

Best Answer

Here's a solution in R based on the OP's comments:

#Load the three packages below 
 library(sp)
 library(raster)
 library(rgdal)

##Load Raster

r <- raster("path to raster")
fun <- function(x) { x * 10 } #function you want to use here, am multiplying   all cells by 10
rc <- calc(r, fun) #Performs a raster calculation 

##WriteRaster to a .tif

writeRaster(rc, "C:\\...\\newrast.tif", format="GTiff")

Note, you could write a loop, if you have multiple rasters to start with, or alternately explore the stack function in the raster package to stack them and run the calc function on that stack, and then write it out.

Example:

rast <- stack(r1,r2,r3,r4) #Note they have to be of the same extent and resolution

fun <- function(x){ x * 10}
rc_stack <- calc(rast, fun)

##Writing it out, by keeping old names

newname<-paste("C:\\Users\\",names(rast)) #Saves the previous names
writeRaster(rc_stack, newname, bylayer=T, format="GTiff")
Related Question