Python 光栅源形状与给定的索引1不一致

Python 光栅源形状与给定的索引1不一致,python,geotiff,rasterio,Python,Geotiff,Rasterio,我需要保存一个3波段的geotiff文件。我目前正在使用rasterio,当我要写出3波段图像时,我得到错误源形状(134454703,4)与给定索引1不一致 我的最终目标是能够对图像执行一些分析并将其写入文件 我已经尝试了将图像重塑为光栅和将图像重塑为图像。我已经尝试了一些其他的组合以及.transpose(arr,(0,1,2)) 我希望在文件中保存一个geotiff。相反,我得到: rasterio中的VALUERROR rasterio_io.pyx._io.DatasetWriter

我需要保存一个3波段的geotiff文件。我目前正在使用rasterio,当我要写出3波段图像时,我得到错误
源形状(134454703,4)与给定索引1不一致

我的最终目标是能够对图像执行一些分析并将其写入文件

我已经尝试了
将图像重塑为光栅
将图像重塑为图像
。我已经尝试了一些其他的组合以及.transpose(arr,(0,1,2))

我希望在文件中保存一个geotiff。相反,我得到:

rasterio中的VALUERROR rasterio_io.pyx._io.DatasetWriterBase.write()

ValueError:源形状(13445,44703)与给定的不一致 索引1


看起来您正在尝试编写一个4波段光栅

rio将(134454703,4)解读为1个波段、3445行、4703列和4个其他维度……我不是rio专家

如果您想保留您的4个乐队:

naip_data2 = np.moveaxis(naip_data.squeeze(),-1,0) # move axis with 4 entries to beginning and remove extra dimension

print(naip_data2.shape) # check new shape, should be (4,3445,4703)
print(naip_meta) # check that naip_data2.shape == (naip_meta['count'],naip_meta['height'],naip_meta['width'])

# if they are equal, naip_meta doesn't need to be updated, otherwise update it
with rio.open(fname,'w',**naip_meta) as dst:
    dst.write(naip_data2)

我也有同样的问题。我通过删除'index'参数解决了这个问题

因此,不是:

dst.write(image,indexes=3)
使用以下命令:

dst.write(image)

我找不到有这个问题的人,有什么帮助吗?
dst.write(image)