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?

  • 1
    What is "/assing"? – PolyGeo Feb 22 '18 at 0:10
  • 1
    Sorry i mean assign – Marco Miglionico Feb 22 '18 at 0:12
  • Are you sure that the value isn't supposed to be 255 and is being not drawn because the nodata value is set to 255? How does it look if you set the nodata to 256 (out of range)? It's kind of hard to tell with your sample area if it could be expected to be very bright. One way to fill with adjacent values is to convert your raster to points then interpolate the points, it is tedious doing it that way though. If you're not too fussy about the value that gets filled have a look at gis.stackexchange.com/questions/120840/… and see if that helps – Michael Stimson Feb 22 '18 at 1:48
  • The area considered is much bigger, in this screenshot i took just a part,so i think that an interpolation can work because in general the area with no value are not so many. Anyway yes the area with value 255 represent no measurement – Marco Miglionico Feb 22 '18 at 17:49

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.
| improve this answer | |
  • 1
    Thank you, this was very useful, the missing values were filled. – Marco Miglionico Feb 22 '18 at 18:23
  • I had been looking for exactly this answer! – Shawn May 21 at 4:19

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.