使用rio.plot.show后如何添加颜色条? 我尝试了很多方法,但都出现了各种错误
以下是我尝试的一种方法:
fig, ax = plt.subplots(figsize = (16, 16))
retted = rio.plot.show(ds, ax=ax, cmap='Greys_r')
fig.colorbar(retted, ax=ax)
plt.title("Original")
plt.show()
这有错误:AttributeError: 'AxesSubplot' object has no attribute 'get_array'
我同意这个解决方案,但我想补充一点,如果你和我一样,我通常有一个
rasterio datasetreader
对象(使用rasterio.open
读取georeffed光栅数据的结果),而不仅仅是一个原始numpy数组。因此,对于RasterioV1.1.8,我必须执行额外的步骤,从datasetreader对象提取numpy数组。例如,对于单个波段:(我想加上这句话作为评论,但没有声誉点)
我做了上面david建议的事情,它成功了
相关问题 更多 >
编程相关推荐