1

I am trying to to compose a RGB .TIFF image using rasterio with bands that I've downloaded from sentinel-2 (via sentinelsat). The resulting image is black.

import rasterio

# Open Bands 4, 3 and 2 with Rasterio
R10 = 'S2B_MSIL2A_20190605T100039_N0212_R122_T33TTG_20190605T143319.SAFE/GRANULE/L2A_T33TTG_A011731_20190605T100530/IMG_DATA/R60m'
b4 = rasterio.open(R10+'/T33TTG_20190605T100039_B04_60m.jp2')
b3 = rasterio.open(R10+'/T33TTG_20190605T100039_B03_60m.jp2')
b2 = rasterio.open(R10+'/T33TTG_20190605T100039_B02_60m.jp2')


# Create an RGB image 
with rasterio.open('RGB_large.tif','w',driver='GTiff', width=b4.width, height=b4.height, 
              count=3,crs=b4.crs,transform=b4.transform, dtype=b4.dtypes[0]) as rgb:
    rgb.write(b2.read(1),1)
    rgb.write(b3.read(1),2)
    rgb.write(b4.read(1),3)   
    rgb.close()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.