QGIS Raster – Filtering Raster by Pixel Value Using GDAL in QGIS

filtergdalqgisraster

I have downloaded Globcover data in GeoTIFF format. I want to create a new grid which only has values where the Globcover data (the only band in the TIF file) has one certain value (==190).

Can I do this with GDAL?

If not, which way should I go? The procedure should be callable from a Shell script (Linux). I have QGIS installed (but no clue how to use it).

Best Answer

In QGIS you have the raster calculator (Under the "Raster" menu) which will do what you want. (not a shell script command)

  • Load your Globcover raster into QGIS, and open the Raster Calculator.
  • The raster will appear in the "Bands" window.
  • Enter a name for the new "Output Layer".
  • Now double click on the Globcover band name so that it appears in the lower "Raster calculator expression".
  • Then complete the expression by typing "=190" in that window.
  • Click OK to create the new raster.

Note that you will have a raster with values of either 190 or 0 everywhere else. You can further use gdal_translate to set the zeros to NULL.

HTH, Micha