[GIS] How to use gdal_calc.py for multi-band images

gdalmulti-bandnumpyraster

My problem is that I have multi-band images (8 bands) in GEOTIFF format and I tried to use gdal_calc.py to calculate a conditional expression between those bands. However, I could not make it because of wrong syntax. The source page does not give any example about this problem.

Best Answer

To calculate a grey-scale from the same input file using different bands u can open the file multiple times and define the band which you want to use with --A_band=n.

See my example for calculating the NDVI from a satellite image with red at band 1 and near-infrared at band 4.

gdal_calc.py -A input.tif --A_band=1 -B input.tif --B_band=4 --outfile=ndvi.tif --calc="((B-A)/(B+A))"

You can see that I used input.tif for A and B. See documentation of gdal_calc.py: http://www.gdal.org/gdal_calc.html

Related Question