16

When I process a raster in QGIS it creates a second band. It appears that the band has no useful data. I like to use the Raster Colours Tool and it will not accept a raster with anything more than one band.

How do I remove the extra band?

Taras
  • 32,823
  • 4
  • 66
  • 137
BWill
  • 1,772
  • 1
  • 16
  • 27
  • 1
    What raster processing are you doing that creates the extra band? It sounds like it is generating a mask band. – MerseyViking Apr 25 '11 at 13:37
  • I am using the new clipper tool in QGIS 1.7. It is a GDAL_TRANSLATE implementation as far as I know. I use a shapefile mask layer and a no data value of 0. – BWill Apr 25 '11 at 14:46

4 Answers4

9

select in Toolbox: Rearrange bands. And remove band

Vsevolod Tsukanov
  • 1,047
  • 8
  • 13
  • By far the easiest option! Especially if you just want to drop just one band from a multi-band raster. – EcologyTom Jun 23 '21 at 14:41
  • Well, I select one band (the one to keep) and after processing, the other bands are still in the new product. – Sebastian H Apr 10 '23 at 11:53
  • Maybe you have some specific raster that the algorithm cannot process, try resaving it to another format, I just tried the PNG 4 bands file, everything is fine, only the selected band remains... – Vsevolod Tsukanov Apr 10 '23 at 20:47
8

Interesting. If you specify a shapefile as a mask, it uses gdal_warp, and automatically adds -dstalpha to the commandline options.

For now, you could copy the text that appears at the bottom of the dialog box, and paste it into a command line window, removing the -dstalpha option. But this isn't an ideal solution, so I suggest you file a ticket on the QGIS bug tracker to get it added as an option.

As an alternative but sticking with the command line, you could run gdal_translate on your two-band file, using the option -b 1 to just use the first band for the output.

Band control is definitely something worth having in QGIS I reckon, so it might be worth adding that to the bug tracker as a requested feature.

MerseyViking
  • 14,543
  • 1
  • 41
  • 75
0

Try "GDAL miscellaneous raster calculator". I had the same problem. In the dialog box choose the raster file for the A band, and leave the other band as not selected. In the calculation gdalnumeric command text box type A*1. The raster file created will have only one band.

Francis
  • 169
  • 2
  • 8
0

You can just use QGIS raster calculator:

Expression: "my_raster@1"

Click current layer extent

and save as a new single band raster.

user2821
  • 398
  • 3
  • 16