当前位置:   article > 正文

FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will……_returning scalar instead, but in the future will p

returning scalar instead, but in the future will perform elementwise compari

项目场景:

读取遥感影像


问题描述

FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
if im_data == “None”:

   	dataset = gdal.Open(image)
    im_geotrans = dataset.GetGeoTransform()  # 仿射矩阵
    im_proj = dataset.GetProjection()  # 地图投影信息
    im_data = dataset.ReadAsArray()  # 将数据写成数组,对应栅格矩阵,读进来后空值会变为0
    im_data =np.where(im_data == 0,np.nan,im_data) # 将0设置为空值
    if im_data == "None":
        print("无法打开数据")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

原因分析:

元素比较失败


解决方案:

if im_data == "None":替换为if im_data is None:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/458190
推荐阅读
  

闽ICP备14008679号