Mar-27-2019, 12:13 PM
Hello.
I want to automate this code below for other 99 images, the problem that I have is that each image is in its specific folder as it's mentioned in the picture below.
the images are very big and I want to clip them in a specific area, is that possible to make it automatic also ?
I want to automate this code below for other 99 images, the problem that I have is that each image is in its specific folder as it's mentioned in the picture below.
import rasterio import os from rasterio import plot import matplotlib.pyplot as plt import numpy as np os.chdir(r'Z:\New folder\S2\L1C_T29SPR_A003995_20160328T111353_2016-03-28\New folder\CLIP') band4 = rasterio.open(r'Z:\New folder\S2\L1C_T29SPR_A003995_20160328T111353_2016-03-28\New folder\CLIP\clip_RT_L1C_T29SPR_A003995_20160328T111353_B04.tif') #red band5 = rasterio.open(r'Z:\New folder\S2\L1C_T29SPR_A003995_20160328T111353_2016-03-28\New folder\CLIP\clip_RT_L1C_T29SPR_A003995_20160328T111353_B08.tif') #nir plot.show(band5) band4.dtypes red = band4.read(1).astype('float32') nir = band5.read(1).astype('float32') ndvi=np.where( (nir+red)==0., 0, (nir-red)/(nir+red)) ndvi[:5,:5] plot.show(ndvi) plt.colorbar (ndvi) #I have also a problem with colorbar as it didn't show properlyThank you