1

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

  • Tell more details, at least size of the image, is it compressed (use gdalinfo), and what output format you have defined. – user30184 Jan 10 '17 at 8:44
  • @user30184 : check now – User18 Jan 10 '17 at 8:53
  • What operating system? 32 or 64bit QGIS? – user2856 Jan 10 '17 at 9:18
  • 32 bit QGIS . OS is 64 bit – User18 Jan 10 '17 at 9:22
  • 1
    Why using QGIS 32 bit if your OS is 64 bit!? – Albert Jan 10 '17 at 9:33
2

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")
1

I had the same error. My solution was to check the layer extent, because when you open the Raster Calculator the extent is very big so clicking on the button Layer Extent can resolve your problems. In my case it was the solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.