I have a multi image tif with 7 bands and I try to use rastrio package to create a simple calculation. I follow the docs but that not work for me.
any idea ?
here the code:
with rasterio.open('L7.tif') as src:
#b1, b2, b3, b4, b5 = src.read()
blue = src.read_band(1)
green = src.read_band(2)
red = src.read_band(3)
nir = src.read_band(4)
profile = src.profile
profile.update(
dtype=rasterio.float64,
count=1,
compress='lzw')
MI = numpy.zeros(blue.shape)
MI = (blue *green*red *nir )
with rasterio.open('ndvi_python.tif', 'w', **profile) as dst:
dst.write(NDMI.astype(rasterio.float64), 1)
error :
blue = src.read_band(1)
AttributeError: 'DatasetReader' object has no attribute 'read_band'
if I try to :
with rasterio.open('L7.tif') as src:
b1, b2, b3, b4, b5 = src.read()
then I take this error :
b1, b2, b3, b4, b5 = src.read()
ValueError: need more than 1 value to unpack