[GIS] Interpolating parts of raster layer in QGIS

interpolationqgisraster

I have the following raster layer enter image description here

The part in black have a value of 255, while the yellow parts have other values that goes from 0 to 255 depending on the color. The black part are the one that i want to interpolate since they have a value of 255 because no value were present, so it is like they are null values.

Is there a way to interpolate/assign a value to the black parts and obtain a raster layer without them?

Best Answer

Given your value 255 is not set as nodata ("it is like they are null values"), I would suggest two steps - (1) Assign 255 as your Nodata cell. (2) Fill Nodata cells.


(1) Set Nodata cell by gdal_translate

  1. From QGIS Processing Toolbox, activate GDAL/OGR | [GDAL] Conversion | Translate (convert format).
  2. There is an entry: Nodata value, leave blank to take the nodata value from input. Give it 255.
  3. Expand Advanced parameters (small black triangle), where you will see Output raster type. Select Byte.
  4. Click on Run. You will get a new layer Converted.

(2) Fill holes by Fill Nodata cells

  1. From QGIS menu, open Raster | Analysis | Fill nodata. Select Converted as the Input layer.
  2. Set Output file name to be the output and click on Run.

Footnote about the choice of tool for (1) handling nodata value:

  • GRASS has r.null tool which specifically handles nodata value. Today I had difficulty using this tool as it changed grid size for some unknown reason. (But it may worth a try).
  • SAGA also handles nodata through its Reclassify values tool, but the output becomes Float32 grid (SAGA default setting).
  • So I assumed gdal_translate is the tool to change nodata value for Byte-type dataset.
Related Question