# Assign RasterB values to RasterA where B != no value in QGIS Raster Calculator

QGIS raster calculator is confusing me and I have no idea how to perform a very simple task.

I have 2 rasters, A and B:

Raster A has 9999 values on all pixels. Raster B has different values including no data pixels.

I want Raster A pixel to = Raster B pixel where B != null

Which means Raster C(output) is 9999 Except where Raster B has values

• What have you tried? See for example something like: Conditional calculation - QGIS Raster Calculator or GRASS r.mapcalculator
– Bera
Commented Mar 3, 2020 at 15:27
• I tried this, didn't work: (("slope_clipped@1">0) * "9999@1" = "slope_clipped@1") + (("slope_clipped@1">0) * "9999@1" = 9999) I.E.: if(rasterB_pixel >0){ rasterA_pixel = rasterB_pixel } else{ rasterA_pixel = 9999 //do nothing } Commented Mar 3, 2020 at 15:51

``````("slope_clipped@1" > 0) * "slope_clipped@1" + ("slope_clipped@1" = 0) * 9999
You can do it without raster calculator, using Fill NoData cells. Input is Raster B, `Fill value` is 9999.