A raster might have one or more bands. Bands represent layers of information within a raster. Each band has the same number of columns and rows.
We will again use the SatImage raster available at https://geospatialpython.googlecode.com/files/SatImage.zip.
Place this raster in your /qgis_data/rasters
directory.
We will load the layer and then print the band count to the console. To do this, we need to perform the following steps:
rasterLyr = QgsRasterLayer("/qgis_data/rasters/satimage.tif", "Sat Image") rasterLyr.isValid()
3
in this case:rasterLyr.bandCount()