Monday, 14 October 2019

QGIS Raster Calculator: Need values to be set to 0 instead of no data


I have a landcover map with different values for the landuse options e.g. 190 for commercially used areas. Now I want to extract only these areas using the Raster Calculator with the expression




"Raster@1" = 190



This works fine, the resulting Raster contains value 1 for all cells which where 190 before (as it is supposed to) but no data values (high negative values) for all other cells, which I need to be zero instead. When I did the same operation to other rasters, QGIS would set the other cells to 0, which in this case is necessary for me to add the result raster to another raster later on.


Any ideas how I can avoid that QGIS sets the cells to no data cells? And what could be a reason that it deals differently with rasters of the same format when applying the same operation with the raster calculator? Both rasters are .tif but from different sources.



Answer



Within QGIS, I find the raster calculator a little limiting, but you can use the SAGA processing tool "Reclassify grid cells" (Processing Toolbox > SAGA > Grid-Tools


In the parameters, you can select "[1] range" for method, provide your range, and select 0 for "new value for other values".


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