Truecolor da dati Sentinel 2 usando RasterIO
L'immagine e' stata corretta nel contrasto per renderla piu' leggibile
import rasterio
from rasterio import plot
imagePath = './immagini/'
band2 = rasterio.open(imagePath+'B2.jp2', driver='JP2OpenJPEG') #blue
band3 = rasterio.open(imagePath+'B3.jp2', driver='JP2OpenJPEG') #green
band4 = rasterio.open(imagePath+'B4.jp2', driver='JP2OpenJPEG') #red
band2s = band2.read(1)
band3s = band3.read(1)
band4s = band4.read(1)
bandg2=2.5*(band2s.astype(float))
bandg3=2.5*(band3s.astype(float))
bandg4=2.5*(band4s.astype(float))
trueColor = rasterio.open('./immagini/SentinelTrueColor2.tiff','w',driver='Gtiff',
width=band4.width, height=band4.height,
count=3,
crs=band4.crs,
transform=band4.transform,
dtype=band4.dtypes[0]
)
trueColor.write(bandg2,3) #blue
trueColor.write(bandg3,2) #green
trueColor.write(bandg4,1) #red
trueColor.close()
Nessun commento:
Posta un commento