下面是一个示例代码,使用了 rasterio 库来读取 TIF 格式的遥感影像并进行波段拆分:
import rasterio
# 读取 TIF 格式的遥感影像
with rasterio.open('image.tif') as src:
image = src.read()
# 获取影像的波段数量
bands, height, width = image.shape
# 拆分每个波段并保存
for i in range(bands):
band = image[i, :, :]
with rasterio.open(f'band_{i}.tif',