图像将不显示:dtype对象的图像数据无法转换为浮点

2024-05-17 04:04:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试让python读取geoTIFF图像,但在尝试让图像显示时遇到困难

import rasterio as r
import numpy as np
import matplotlib.pyplot as plt    

FNF=r'D:\\Iceberg data\\RADARSAT\\RS2_SLC_geotif\\roi20m_RS2_20160415_153940_0004_FQ13_HHVVHVVH_SLC_470697_4660_12996414_Geo.tif\\'
    raster = r.open(FNF)
    
    print(raster)
    raster.bounds
    raster.height
    raster.width
    raster.transform
    raster.get_transform()
    raster.tags(1)
    xmin=raster.bounds[0]
    ymax=raster.bounds[3]
    raster.read(1)
    
    fig = plt.figure(1)
    plt.title('SLC image')      # this defines the title 
    plt.imshow(raster)

我用imshow得到了错误。我做错了什么

当我做{i: dtype for i, dtype in zip(raster.indexes, raster.dtypes)}的时候,我得到了float32


Tags: 图像importtitleastransformpltgeotiffdtype