import rasterio # import the main rasterio function
import matplotlib # matplotlib is the primary python plotting and viz library
import matplotlib.pyplot as plt
# this bit of magic allows matplotlib to plot inline in a jupyter notebook
%matplotlib inline
import numpy as np
from rasterio.plot import show
img='/work/LE70220491999322EDC01_stack.gtif'
data=rasterio.open(img)
print(data)
bands=data.count
print(bands)
rows, col=data.shape
print(rows, col)
desc=data.descriptions
meta=data.meta
print(desc)
print(meta)
driver=data.driver
print(driver)
prj=data.crs
print(prj)
gt=data.transform
print(gt)
nir=data.read(4) #open the 4th band of image which is near infrared
nir.shape # check dimensions
datatype=data.dtypes # check bands data type
print(datatype)
# display entire image
full_img=data.read()
full_img.shape # bands, rows, col
# plot image nir band
show(nir, transform=data.transform, cmap='gray')
# we can also use matplotlib to show nir band
plt.imshow(nir)
plt.colorbar()
plt.title('Overview - Band 4 {}'.format(nir.shape))
plt.xlabel('Column #')
plt.ylabel('Row #')