I merged 102 Tiff files downloaded from ASTER: https://earthexplorer.usgs.gov/.

They were each 17 MB, plus or minus. I merged them using the Processing toolbox/GDAL merge tool. I am trying to use the raster calculator on it, but I get an error message saying Insufficient memory available for the operation. The pixel type is float 32, and I heard at my previous question that this may be making the file size too big.

About my computer:
7.8 GiB of memory
32 bit
483.8 GB disk space (128.5 used)
Ubuntu 16.04 LTS
QGIS 2.18.11

I have tried changing the pixel type with GDAL Translate, but I get an error message saying no output file was created: enter image description here

When I use r.mapcalc to do the raster calculation, I click run and it seems to work, but no file is saved and no layer appears. I tried using both the name of the file in the Layers panel and its filename.

enter image description here enter image description here

I could try merging the different rasters into small groups, but idoes anyone know an easier way?

  • 1
    What's your calc? It doesn't seem right that you're out of memory, GDAL is usually pretty good at that.. your disc space: is that system drive as well? Would you consider doing the calc in python? – Michael Stimson Apr 13 '18 at 3:16
  • The ASTGMT2 source dem files are 16 bit signed interger – Jakub Sisak GeoGraphics Apr 13 '18 at 13:44

Well, judging by the first screenshot you provided, seems to me that you are not specifying the output file to produce to the translate, which you should:

enter image description here

This is probably the reason why you get the "no output file created" warning.

Besides that, I don't see why you could be running out of memory from a rastercalc. Seems that 102*17MB is 1734MB, or about 1.7GB. Personally, I have run raster calculations (NDVI, etc.) on Tiff files of about 3GB without problems at all; sure it's takes some time but it outputs the calculation.

Some other things you could check are:

  • Make sure the output folder for your calculation has write permissions.
  • Check if that disk space is really what you have available, perhaps your partition or similar has less space available.
  • You can also try doing what suggested here, and use r.mapcalculator or well gdal_calc

Alternatively, you can consider loading your Tiff on Python and doing the calculation on your bands there. The way I do it is to open the file with OpenCV (or with imread for large images) and then operate it with a Numpy array, something like:

from skimage.io import imread
import numpy as np
#read image
img = imread("yourImage.tif")
#load as float 32 Numpy array
img = np.float32(img)

#then do your calculations, for example NDVI:
#Using Python's slicing, operate on all pixels by bands
ndvi = (img[:,:,0] - img[:,:,2]) / (img[:,:,0] + img[:,:,2])

You can then use your calculation ndvi as you wish.

  • I was able to convert to Int16 thanks to you, but the raster calculator still said there was not enough available memory. I'll try the other options. – mmmm Apr 14 '18 at 2:06
  • Ok, surely python wont fail. As a side note, remember that numpy loads into memory (RAM) so if your array is N kb it will take N kb from memory – DarkCygnus Apr 14 '18 at 6:06

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.