# Using flat (no data) areas of aspect-raster in QGIS raster calculator?

I´m playing around with the Raster tools in QGIS, following more or less the qgis-tutorial but using my own data. When I calculate the aspect of a DEM, flat areas are (logically) left without data. However, when I try to make an addition with another rather afterwards in the raster calculator, the flat areas (no data in my aspect layer) are never taken into consideration, even if the raster I use for addition has data in this area.

For example: Let´s say I´m looking for places facing south (135-225°) with slopes less than 15%. To find these places I have two rasters:

• Raster A: aspect 135-225° has the value 1, the rest 0 and flat areas without aspect have no data (the appear transparent)
• Raster B: slopes less 15% have the value 1, the rest 0

If I combine the two rasters in the Raster Calculator (e.g. like this: "ANP_aspect_sur@1" = 1 AND "ANP_slope_15@1" = 1), the output file has no data where Raster A has no data, independent of Raster B.

What am I doing wrong?

I thought about setting flat areas to 0 (-zero_for_flat). But in this case 0 would stand both for north in regards of the aspect and for nodata.

As far as I know ArcMap assigns -1 to flat areas.

• It's not clear what problem you are working around. Could you explain what sense it would make to add an undefined aspect to any other value? Jul 10, 2014 at 21:02
• OK, for example: Let´s say I´m looking for places facing south (135-225°) with slopes less than 15%. To find these places I have two rasters: Raster A: aspect 135-225° has the value 1, the rest 0 and flat areas without aspect have no data (the appear transparent) Raster B: slopes less 15% have the value 1, the rest 0 If I combine the two rasters in the Raster Calculator (e.g. like this: "ANP_aspect_sur@1" = 1 AND "ANP_slope_15@1" = 1), the output file has no data where Raster A has no data, independent of Raster B. Tricky to explain …
– Flo
Jul 10, 2014 at 21:23
• Thank you. I think I follow: you wish to treat zero-slope areas as having all aspects and that can be quite a reasonable thing to do. This is usually handled in aspect calculations by assigning a special code to such areas (such as -1) rather than NoData, which confounds them with actual missing data. But you can easily put such a code back in if you wish, simply by referring to the zeros in the slope grid. Is my interpretation correct? If so, it would help future readers if you were to edit your post to make this point a little clearer. Jul 10, 2014 at 22:14
• Thank you too! In this case my question would be: how can I assign e.g. -1 to the nodata areas. Is this done when I calculate the aspect or afterwards?
– Flo
Jul 11, 2014 at 14:57

You might take a look at the GRASS model r.param.scale. This module is designed to create a categorical raster of geo-morphology. You choose the threshold slope and it creates all "flat" areas with value 0. Then you could easily concoct an `r.mapcalc` expression to extract areas where the aspect is south and the terrain (output of `r.param.scale`) = '0'