Friday, 29 November 2019

Raster calculator reclass 0 as 0 QGIS


I want to process a raster with values 0-16. I want to set all values between 1 and 15 as 1, a value of 16 as 0 and cells with a value of 0 as 0.


How do I maintain a cell value of 0?


I have tried the following:


("raster_name@1" !=0 AND "raster_name@1" <= 15*1)+("raster_name@1" = 16*0)


Results in: Values of 16 as 0, values 1-15 as 1, values 0 also = 1


I also tried:


("raster_name@1" !=0 AND "raster_name@1" <= 15*1)+("raster_name@1" 16*0)+("raster_name@1" = 0*0)

Results in: Values of 16 as 0, values 1-15 as 1, values 0 = 2


Please, can you explain how to retain cells with a 0 value as 0?



Answer



Simply write "raster_name@1" != 0 AND "raster_name@1" <= 15 in order to set all values between 1 and 15 to 1, and everything else to 0.


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...