I have been trying to write a tiff file using a numpy array. The file would have only one band. But when I am writing the file it is printing only 0, provided I have checked that the array is doesn't contain zeros. If I open the output tiff file and see the pixel values, all the values are zero. In the code below, rgb is the array, raster is a geotiff file.
import numpy, sys from osgeo import gdal from osgeo.gdalconst import * #format1='GTiff' gdal.AllRegister() driver = raster.GetDriver() #driver = gdal.GetDriverByName(format1) output = driver.Create("E:/workplace/final/results2/final_result_h.tif", cols, rows, 1, gdal.GDT_Int16) if output is None: print('Could not create final_result_h.tif') sys.exit(1) outBand = output.GetRasterBand(1) outBand.WriteArray(rgb) outBand.FlushCache() outBand.SetNoDataValue(value) output.SetGeoTransform(raster.GetGeoTransform()) output.SetProjection(raster.GetProjection())