Estoy utilizando una imagen hiperespectral con 158 bandas. Quiero calcular la trama. Estoy usando el siguiente script python
import gdal # Import GDAL library bindings
from osgeo.gdalnumeric import *
from osgeo.gdalconst import *
import pylab as plt
import numpy as np
import xlrd
# The file that we shall be using
# Needs to be on current directory
filename = ('C:/Users/KIFF/Desktop/These/data/Hyperion/10th_bandmathref')
outFile = ('C:/Users/KIFF/Desktop/These/data/Hyperion/Math')
XLS=('C:/Users/KIFF/Desktop/These/data/Coef/bcoef.xlsx')
wb = xlrd.open_workbook(XLS)
sheet = wb.sheet_by_index(0)
sheet.cell_value(0, 0)
g = gdal.Open(filename, GA_ReadOnly)
# g should now be a GDAL dataset, but if the file isn't found
# g will be none. Let's test this:
if g is None:
print ("Problem opening file %s!" % filename)
else:
print ("File %s opened fine" % filename )
#band_array = g.ReadAsArray()
#print(band_array)
print ("[ RASTER BAND COUNT ]: ", g.RasterCount)
for band in range( g.RasterCount ):
print (band)
band += 1
outFile = ('C:/Users/KIFF/Desktop/These/data/Results/Temp/Math_1_sur_value'+str(band)+'.tiff')
#print ("[ GETTING BAND ]: ", band )
srcband = g.GetRasterBand(band)
if srcband is None:
continue
data1 = BandReadAsArray(srcband).astype(np.float)
print(data1)
# for i in range(3,sheet.nrows):
b=sheet.cell_value(band+2,1)
#print(b)
dataOut = (1/data1)
driver = gdal.GetDriverByName("ENVI")
dsOut = driver.Create(outFile, g.RasterXSize, g.RasterYSize, 1)
CopyDatasetInfo(g,dsOut)
bandOut=dsOut.GetRasterBand(1)
BandWriteArray(bandOut, dataOut)
para la print(data1)
Tengo sólo algunos "1", pero los valores reales son algunos flotadores
0
[[1. 1. 1. ... 1. 1. 1.]
[1. 1. 1. ... 1. 1. 1.]
[1. 1. 1. ... 1. 1. 1.]
...
[1. 1. 1. ... 1. 1. 1.]
[1. 1. 1. ... 1. 1. 1.]
[1. 1. 1. ... 1. 1. 1.]]
1
[[1. 1. 1. ... 1. 1. 1.]
[1. 1. 1. ... 1. 1. 1.]
[1. 1. 1. ... 1. 1. 1.]
...
[1. 1. 1. ... 1. 1. 1.]
[1. 1. 1. ... 1. 1. 1.]
[1. 1. 1. ... 1. 1. 1.]]
2
Valor de píxel 0,139200
¿Puedes encontrar el error?