I have some .tif raster and .shp mask, and I need to fill values in the raster, which are beyond the mask, with -999. How can I do this using QGIS?

1 Answer 1

  1. Use the Clipper tool which you can find from the menubar:

    Raster > Extraction > Clipper

    And set the parameters using the mask layer:


    This should create an output of your raster within the mask layer and everything outside the mask layer should have a value of 0.

  1. Use the Raster Calculator on the output:

    Raster > Raster Calculator

    And use an expression like the following to change all 0 values (i.e. values outside your masked raster) to -999 whilst all values inside remain the same:

    (("Raster@1" != 0) * "Raster@1") + (("Raster@1" = 0) * -999)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.