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?
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).
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 ) maskband.FlushCache()
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?)