I'm using this code, of @Loïc Dutrieux, to stack 8 Landsat bands.
with rasterio.open(final_list[0]) as src0:
meta = src0.meta
with rasterio.open('stack.tif', 'w', **meta) as dst:
for id, layer in enumerate(final_list):
with rasterio.open(layer) as src1:
#the .astype(rasterio.int16) forces dtype to int16
dst.write_band(id + 1, src1.read(1).astype(rasterio.int16))
When I open the stack.tif with gdalinfo I'm not getting bands' description in the Metadata:
...
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
...
Band 1 Block=3596x1 Type=Int16, ColorInterp=Gray
NoData Value=-9999
Band 2 Block=3596x1 Type=Int16, ColorInterp=Undefined
NoData Value=-9999
...
I would like something similar to this:
...
Metadata:
Band_1=Band 1 Reflectance
Band_2=Band 2 Reflectance
Band_3=Band 3 Reflectance
Band_4=Band 4 Reflectance
Band_5=Band 5 Reflectance
Band_6=Band 7 Reflectance
Band_7=Band 6 Temperature
Band_8=Fmask
Image Structure Metadata:
...
Band 1 Block=300x1 Type=Int16, ColorInterp=Undefined
NoData Value=-9999
Band 2 Block=300x1 Type=Int16, ColorInterp=Undefined
NoData Value=-9999
...
rasterio.__version__ = '0.36.0'. Properties likesrc.descriptionsare not available in my version. if it's a matter of version, please help me to install the newest. Could find any guide in the web – mlateb May 25 '18 at 21:55conda install -c conda-forge/label/dev rasterio. I can't help with any other installation as I only use conda. – user2856 May 25 '18 at 22:06dst.set_band_description(id+1 , src1.descriptions[0])added the band description as following:Band 1 Block=3596x1 Type=Int16, ColorInterp=Gray Description = band 2 surface reflectance NoData Value=-9999. But couln't add info to metadata section. I guess it's due toGTtiffdriver specification. I opened a new question about masking and staking at the same time, please have a look. Thanks in advance! – mlateb May 30 '18 at 15:48update_tagsmethod http://rasterio.readthedocs.io/en/latest/topics/tags.html – user2856 May 30 '18 at 20:50