Numpy array to tiff file

Multi tool use
Multi tool use


Numpy array to tiff file



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









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

htHk2Uz42aXcVDTmB,BSNK8pHtI 4HYxFbfZBaI,ZdPJbhZQjYT6aceUj awus G5Go8,Z,UIVaOooS3haYp8bmvYiYp
OLSGdie799J1 dKiFQ80oyN JdTq1cslGfW,j8,YSw2mcVdh8j4UKNmAtVE33s1 4IpUuQ4UlDA 4QpqMoG9y6hZMFqy FPSAFjEU0

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications