2

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.

1

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

  • Hey, thanks for the answer, all morning this website didn't work properly here so I went back to the study the manual and stumbled upon the SAGA tools as well, finding yet another solution! – Gumbo Jul 29 '14 at 9:15
2

I just found the SAGA tools and the better raster calculator provided. I solved the problem using the following formula:

ifelse(eq(a,190), 1, 0)

which actively sets all cells with a value other than 190 to zero.

Edit: I just found the reason why QGIS dealt differently, too: I was wrong stating that both rasters had the same format. In the first case my input raster was in ASCII format and QGIS set zeros. Doing the same operation with a tif format, it sets no data values.

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.