4

I know this question has been asked already in this forum, but I couldn't find an easy (for me, a rookie) solution for my problem. I have an RGB 3 band file which, in some pixels, has i.e.

R no data
G 147
B 147

This creates problems in the visualization of the raster. I'd like to know how to change those values to 0, enabling the colours to be correctly displayed again. I tried to use an algorithm in the processing tab, but it says SAGA algorithms are not supported by multiband layers. Also I've seen many using GRASS tools, but I really have no clue on how to use GRASS, so I would need a step by step explanation. Consider I am still a newbie with this software so, if possible, I'd like use the easiest method.

Evil Genius
  • 6,289
  • 2
  • 27
  • 40
  • Welcome to GIS:SE @RiccardoBoniardi! There's also GDAL which has the Fill nodata tool, you could access this from the Processing Toolbox. – Joseph Jan 22 '16 at 11:15
  • Some gdal approaches suggested here and GRASS/QGIS Raster plugin options here – dmci Jan 22 '16 at 11:21
  • Hello, thanks for the welcome. I looked into my processing toolbox but i have no such tool as fill no data. I guess i miss some plugin or something (my version is 2.8.4). I also read that the fill no data uses interpolation as a method to fill nodata, but i want them to be replaced with 0 exactly, so i dunno if that method would be suitable. Any ideas? Thanks again – Riccardo Boniardi Jan 22 '16 at 11:23
  • @RiccardoBoniardi - There should be a menu at the bottom of your Processing Toolbox which probably says Simplified interface. If so, change this to Advanced interface to obtain a lot more tools. But yes, you are correct in that interpolation is used for the Fill nodata tool. You should probably have listed which questions you looked at to stop others suggesting the same ones :) – Joseph Jan 22 '16 at 11:32

1 Answers1

5

As Joseph suggested, the Fill nodata tool solves your problem. It replaces NoData values with 0's, in the band of your choice.

You can find it either in Raster > Analysis, or (with a slightly different interface) Processing > Toolbox > GDAL/OGR > [GDAL] Analysis (in QGIS 2.8).

Edit: of course, this assumes that GDAL is correctly installed and can be "seen" by QGIS.

Edit 2: as mentionned, Fill nodata outputs only the processed band. A possible solution would be to split your bands (there's a SAGA tool called Split RGB bands in the processing toolbox), then apply the Fill nodata tool, then merge your bands back (Raster > Miscellaneous > Merge).

ArMoraer
  • 5,649
  • 2
  • 26
  • 48
  • Hello, thanks for the help. I tried the "raster analysis" tool, but the output file i got was single band, so its still not displayed correctly. As i said, the original TIF file is a 3 band file, and i'd need to change all nodata values to 0 for each of the 3 bands. Maybe i did something wrong, but there wasnt much to click =) – Riccardo Boniardi Jan 22 '16 at 11:38
  • You're right, this is a bit more complicated than expected. I updated my answer, hope this will work for you. – ArMoraer Jan 22 '16 at 11:47
  • I will try this method, but i also might have found a workaround. I converted the TIF to a PNG and this fixed the colour visualization problem ofc. Now, i dont really need the 3 bands, i just need a correctly visualized image, probel is, the PNG is not georeferenced. Now, i know there is the geo referencing tool, but i'd like to keep the exact referencing the TIF has, which i can see in the metadata. Is there a way to define image corners coordinates and not arbitrary points for a raster layer? – Riccardo Boniardi Jan 22 '16 at 12:43
  • @RiccardoBoniardi: there is a plugin called GeorefExport that should generate a georeferenced PNG. – ArMoraer Jan 22 '16 at 12:56
  • thanks for the tip, i couldn't find the plugin in the "manage and install plugin" tab, so i downloaded from the developer page, but i don't know how to install it (its not a .dll file as the plugins inside qgis folder). If you could suggest me how to install it, i'd give it a try. Thanks again – Riccardo Boniardi Jan 22 '16 at 13:08
  • @RiccardoBoniardi: you have to check the box "Show also experimental plugins" in the Settings tab of the "manage and install plugin" tool. – ArMoraer Jan 22 '16 at 13:16
  • i tried the plugin but unfortunately it converts the NODATA pixels into 255 pixels for each of the 3 bands, and there is no turning back since i actually need the white pixels (255 for all bands) in the original file, but if all NODATA are visualized as white, the view is even more wrong. Thanks for the try anyway – Riccardo Boniardi Jan 22 '16 at 13:24
  • I also tried the SPLIT RGB command but it returns me an error and cant produce the 3 layers for the bands.. i am afraid i will actually need to georeference manually.. The main problem is that in the georeferencing tool, the image merges with the whie background and i cant see the real corners of it.. this is why i was wondering if there was a way to precisely assign coords only for the corners. – Riccardo Boniardi Jan 22 '16 at 13:27
  • Unfortunately I'm out of advices... You can however change the background color in Project > Project Properties > General. – ArMoraer Jan 22 '16 at 13:35
  • Well, those were useful advices anyway, i will put them to good use. Maybe i will be able to use some script in the future to perform this action in a more professional way. Thanks alot – Riccardo Boniardi Jan 22 '16 at 13:50