I am experimenting with merging landsat bands. My dataset has several B3 bands close together, from landsat 8 and 7.
import rasterio
from rasterio.plot import show
from rasterio.merge import merge
from rasterio.warp import reproject
import os
from matplotlib import pyplot
files_to_merge = []
for file in os.listdir():
if file.endswith(".TIF") and ("GM" not in file):
files_to_merge.append(rasterio.open(file))
test, out_trans = merge(files_to_merge)
show(test)
When I above the above code I get:
The files to merge list has the following objects:
<open DatasetReader name='LE07_L1TP_017015_20210503_20210529_02_T1_B3.TIF' mode='r'>,
<open DatasetReader name='LC08_L1TP_016015_20210504_20210517_02_T1_B3.TIF' mode='r'>,
<open DatasetReader name='LE07_L1TP_017016_20210503_20210529_02_T1_B3.TIF' mode='r'>,
<open DatasetReader name='LC08_L1TP_016014_20210504_20210517_02_T1_B3.TIF' mode='r'>,
<open DatasetReader name='LE07_L1TP_017014_20210503_20210529_02_T1_B3.TIF' mode='r'>,
I am a bit confused why the other raster images arent showing up in the merged image. When I remove the first band I can rerun the merge command:
test, out_trans = merge([files_to_merge[1],files_to_merge[2], files_to_merge[3], files_to_merge[4]])
show(test,cmap='terrain')
This seems better but also not correct. I am a bit confused what is going on - how can I merge all the images correctly? Any help is apperciated I am new to rasterio.