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

User18
  • 509
  • 4
  • 15
  • 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 08:44
  • @user30184 : check now – User18 Jan 10 '17 at 08:53
  • What operating system? 32 or 64bit QGIS? – user2856 Jan 10 '17 at 09:18
  • 32 bit QGIS . OS is 64 bit – User18 Jan 10 '17 at 09:22
  • 1
    Why using QGIS 32 bit if your OS is 64 bit!? – Albert Jan 10 '17 at 09:33
  • Why don't you try it in R? You could perform all your raster calculator operations, along with exporting to a .tif output with 2 lines of code. – Vijay Ramesh Mar 16 '17 at 01:50
  • @VijayRamesh : How it can be done ? – User18 Mar 16 '17 at 07:58
  • Answered below. – Vijay Ramesh Mar 16 '17 at 13:34
  • enter image description here Hi, (1): I would like to know how to get rid of the error "Raster calculator: Insufficient memory available for operation" while calculating the population density of raster layer as you can see in the figure. (2): How to calculate the Water withdrawal, Total Available blue water by using vector layer (Aqueduct layer) which consists of polygons. (3): After getting the results from above process then how can I assess that which part of the country have lack of water resources and where th – 860119 Dec 01 '17 at 13:56

2 Answers2

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")
Vijay Ramesh
  • 1,332
  • 15
  • 46
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.

GeoSharp
  • 3,256
  • 17
  • 28
user109521
  • 11
  • 1