I have taken some time to deal with raster bands. I just wanted to understand the concept. Here is what I have found...

A band can be understood as a sort of layer inside the raster data. A raster is a matrix representation of some data with each cell a discrete value. The matrix has got X and Y size, and, of course, the matrix is georeferenced in the space: the position of the 0,0 and sizeX, sizeY cells are translated into the chosen coordinate reference system. So now, 0,0 cell points to an lat,long place. From then, you can deduce the resolution of the image in meters.

A raster with multiple bands is a raster with multiple matrices. Each matrix covers the same cells than the others. The area is the same for each band, but the values are not (well, they are independent).

What are the differente use cases of bands? Well, plenty of different uses actuallay:

  • When using aerial photos, you have three bands: one the Red channel, one for the Green channel and another one for the Blue channel. "Assembling" the three channels make it look like a photo.
  • But you can go further by adding a 4th band which will deal with transparency (alpha channel): the cells in this matrix will tell the level of transparency of the other bands cells.
  • You can go a little more further by using a mask band. In this one, data are telling if the cell should be displayed or not.
  • Ok, this is the most common use of rasters but there is also a much more complex one: sometimes, data in the bands are not just RGB components but data from different sensors. Most of the time, sattelites have different sensors: temperature, humidity, infrared, altitude, etc. Each band will store an instrument value. That is why SENTINEL2 sattelite rasters are 13 bands rasters. The way to display data are controlled by your GIS software.
  • You can also do some math on the matrices and store the results on another band.

How are the bands stored into the raster file? Well it depends on the format. For example, for tiffs files, the cells are storing all data for each band next to the other band. It means that when you want to display only one band, you have to seek N bytes just to get the data you want. For other formats, the data of each band is stored in a different part of the file.

By the way, I have built some tools to deal with raster bands. They are coded in Python3 with the gdal library and you can use numpy to deal with the matrices and you can read the code in this public repository