7

I want to change the value in all pixels that are currently 0 to 800 in QGIS 2.6.1. 0 is listed as the no-data value in Properties > Transparency. I have unchecked the No Data Value box there. Then I have tried the following.

1) Set Settings > Option > Data Sources > Representation for NULL Values = 800. Save as... to make a new .tif raster layer, WITH and WITHOUT specifying a range for No Data Values in the Save As... dialog. I thought that maybe a range from -1 to 1 would handle real-representation zeroes better. Either way, the raster returned is just like the original, with no change to the no-data (value=0) pixels.

2) Processing Toolbox > Geoalgorithms > Raster > General Tools > Raster Calculator, with expression: ifelse(lt(a,1), (800), a). Still no dice, the no-data value is now -99999.

3) Raster menu > Raster Calculator, with expression: ("my layer here@1" >= 0) * "my layer here@1". Interestingly, now the no-data value is -3.40282...E+38.

4) Processing Toolbox > Geoalgorithms > Raster > Edition > Reclassify Grid Values. This tool didn't work at all. Tried [0] Single, [1] Range, and [2] Simple Table options, with and without saving to a file. Log gave a bunch of errors about being unable to load modules. The path to the .dlls is correct.

5) Processing Toolbox > Geoalgorithms > Raster > Edition > Reclassify (Simple), with range option -1 to 1. Returned a raster with the no-data value = -99999.

For the record, all tests were done with the Null Representation = 800, but I also tried several of the methods with the default representation of NULL. Results were the same. I have also exported the raster as XYZ format and looked at it in CloudCompare; the null values are being expressed as the value reported in Properties > Transparency.

5

You can use the r.null.to function via GRASS to transform all NULL value cells into a user-defined value, which in your case is 800:

r.null.to

Note: You will have to create a GRASS Mapset before you can use r.null.to as it is not available in the Processing Toolbox. Once you created a mapset, use the GRASS option to add a raster layer, select Open GRASS Tools and search the Module list:

GRASS Tools

Module list

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.