1

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
  1. Use the Clipper tool which you can find from the menubar:

    Raster > Extraction > Clipper
    

    And set the parameters using the mask layer:

    Clipper

    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, privacy policy and cookie policy

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