numpy array to tiff file

by Naman   Last Updated July 13, 2018 10:22 AM

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 *

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')

outBand = output.GetRasterBand(1)

Related Questions

Determine size of GeoTIFF header

Updated August 20, 2018 00:22 AM

Batch conversion of tif to raster - kernel dying

Updated January 31, 2019 20:22 PM

gdal_translate defaults?

Updated August 23, 2018 19:22 PM