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

Why result of merge of multiple raster is so big?

Updated July 23, 2018 22:22 PM

Merge DEM TIFF grids and get average value

Updated June 20, 2017 12:22 PM