In my raster layers the value -999 means "missing". Those points completely mess up any colormap in qgis because qgis treats them as normal values and includes them in the classification.

I would like to ask

1) is there any raster format that allows for missing values ? (I mostly use geotiff)

2) how can I replace -999 with for example 0 in every raster-cell? QGIS raster-calculator does not seem to do this. I did not find anything like an inline if-function like if(val=-999,0,val)

  • Welcome to gis.stackexchange @stn. Please try to ask only one question per thread. In this case #3 should be move to a separate topic because it can be answered totally independently of your first questions.
    – underdark
    Apr 3, 2012 at 16:29

3 Answers 3


Two options are available

You can either set values to zero '999 -> 0' or remove them entirely from the raster '999 -> nodata'.

  1. Set to zero '999 -> 0' with the raster calculator (Raster > Raster Calculator):

    ("my_rasterA@1" > -999) * "my_rasterA@1"

  2. Set to NA '999 -> nodata', use Translate (Raster > Conversion > Translate) Save the output from the previous step with the raster calculator and use it as the input for this step.

    gdal_translate -a_nodata 0 -of GTiff "C:/Users/Desktop/my_rasterA.tif" "C:/Users/Desktop/my_output.tif"

*** note: when using translate be sure to add the -a_nodata 0 in the little editing window at the bottom & click ok while you are still in editing mode.


If you are only creating a map you can hide these values in QGIS by going to your layer properties --> transparency and then selecting the values you want to hide.

You can also use gdalwarp to replace the missing values as such:

gdalwarp -srcnodata -999 -dstnodata 0 source.tif output.tif

enter image description here

  • For grayscale-maps this is not much of a problem. You can set min and max and transparancy and it works. Single-channel-color-maps on the other hand refuse to honor the transparent values. The "classify"-button always produces -999 as the minimum
    – stn
    Apr 3, 2012 at 19:44
  1. GeoTIFF with NODATA value set to your liking. If set correctly, QGIS should ignore them in colormaps.
  2. eq( [input]@1, -999, 0 ) NOTE: this is a command for RasterCalc plugin (available via plugin installer, also needs pyparsing), this is not for embeded Raster Calculator.
  3. Why not ASCII GRID for doing change you need? Raster\Convertion\Translate, choose output filename with type Arc/Info ASCII GRID You can also try: gdal2xyz
  • GeoTIFF with NODATA works, thanks. In the german version of QGIS this matter is very confusing because the setting is called "Kein-Datum-Wert" which means "No-Date-Value" or "No-Datum-Value". It does not mean anything like "No-Data-Value". Thanks for clearing this up for me.
    – stn
    Apr 3, 2012 at 20:00
  • The ASCII-GRID/gdal-question has been moved to gis.stackexchange.com/questions/22791/…. gdal2xyz is perfect for exporting the data. The real problem is not getting data out, but getting processed data back in, with the correct projection and coordinates etc. That is very easy for vector-layers (just open the dbf of a shapefile in oo-calc) and apparently very difficult for raster.
    – stn
    Apr 3, 2012 at 20:02

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.