我需要将一个三频段的geotiff文件保存到磁盘上。我目前正在使用rasterio,但是当我尝试写出这个三频段图像时,我遇到了错误信息Source shape (1, 3445, 4703, 4) is inconsistent with given indexes 1
。
我的最终目标是能够对一幅图像执行一些分析并将结果写出到文件中。
我已经尝试过reshape_as_raster
和reshape_as_image
。我也尝试了其他一些组合,比如.transpose(arr, (0,1,2))
https://rasterio.readthedocs.io/en/stable/topics/image_processing.html#imageorder
with rio.open(r"C:\Users\name\Documents\project\name.tif") as src:
naip_data = src.read()
naip_meta = src.profile
image = reshape_as_raster(naip_data)
with rio.open('C:\\Users\\name\\Documents\\UAV_test_save\\filename.tif', 'w',**naip_meta) as dst:
dst.write(image, 3)
我希望能够保存一个geotiff文件,但实际得到的是:
rasterio_io.pyx中的ValueError在rasterio._io.DatasetWriterBase.write()中
ValueError: 源形状(1、3445、4、4703)与给定索引1不一致