Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an image which i cliped with an AOI polygon. The contour area was set to pixel value = 0 and I have a nodata value of -32768. I want to redefine the nodata value into zero. I used to do this with ArcMap easily in the raster calculator, but in QGIS I don't see how i could do it. Any ideas?

share|improve this question
Do you want it purely for visualization or you need to set it to null wherein you will conduct further raster calculations? – maning Jul 20 '11 at 11:14
up vote 7 down vote accepted

I found a solution for this. First i convert the image into a vrt layer (gdalbuildvrt) with -srcnodata 0, then i translate it back into a tif file with gdal_translate -a_nodata. Worked fine! :)

share|improve this answer

In QGIS, you can use Raster Calculator with the following calculation:

("your_raster" != -32768) * "your_raster"

With this calculation, if the cell value is -32768 you will get a 0 in that cell and if it is different from -32768 the cell will keep the value it had.

share|improve this answer

I guess you can do that with the raster calculator.

If not with the help of GRASS plugin and r.null you will do it easily. That option means you will have first to create a GRASS mapset to import your raster in.

share|improve this answer
Thank you simo! – vascobnunes Jul 20 '11 at 10:50
could you elaborate on how to do that with raster calculator? – rudivonstaden Dec 2 '12 at 10:48

Having the same problem, in the end I used Python directly -- you may have to adjust numpy.where for your specific purpose. In the case below, the pixel values are kept as they are if they are >= 0, all other pixels -- in this case this is only ones with the no-data value -- are set to "0"

import gdal, gdalconst, numpy
maskfile = gdal.Open('C:\Users\max\Desktop\Baltic2.tif', gdalconst.GA_Update)
maskraster = maskfile.ReadAsArray()
maskraster = numpy.where((maskraster >= 0), maskraster, 0 ) 
maskband = maskfile.GetRasterBand(1)
maskband.WriteArray( maskraster )
share|improve this answer

I have tried using both rastercalc plugin and Raster Calculator and neither worked - Syntax error. What did work was the Warp tool and specifying the source and destination nodata values (see underdark's answer to a similar question How to exclude missing values from raster layer?)

share|improve this answer

The simplest one-step and, IMO, most consistently reliable solution to reclassifying NoData to zero is to use the Reclassify Grid Values tool (SAGA) in the processing toolbox.

After selecting the raster to be reclassified, simply scroll to the bottom of the dialog, ensure the box replace no data values box is checked. The default value is zero (but you can substitute something else of course). Then uncheck the replace other values box and leave all other fields alone (so all you are doing is ensureing one box is checked and unchecking another - no other settings are required).

share|improve this answer
I agree. Nothing else really worked for me (my nodata value was something like -3.4e+38). – ArMoraer Apr 28 at 13:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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