Friday, 10 March 2017

qgis - Change NODATA pixel value in raster to arbitrary value


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.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...