学习python努力gogogo 2022-08-03 21:35 采纳率: 100%
浏览 293
已结题

对影像正射校正时出现ERROR 4: `GF1_.tiff' not recognized as a supported file format.的错误,请教一下如何解决

问题遇到的现象和发生背景

想通过python实现对高分影像正射校正,在网上找的代码修改之后一致运行不同,出现了这样的错误:ERROR 4: `GF1_WFV3_E115.0_N35.6_20190614_L1A0004059202_2.tiff' not recognized as a supported file format.。

问题相关代码,请勿粘贴截图
import os, glob
import time

import gdal, osr
import tarfile
import math

path = "D:\\ENVI\\Data\\shiyan0614\\1\\GF1_WFV3_E115.0_N35.6_20190614_L1A0004059202"
os.chdir(path)

tif_files = glob.glob("*.tiff")
#print(tif_files)
filename = os.path.basename(path)
#print(filename)
lon = float(filename.split('_')[2][1:])
zone_ = int (math.ceil(lon / 6)) +30
zone = int ("326" + str(zone_))
#print(zone)

inputfile = gdal.Open(tif_files[0])
outputfile = tif_files[0][:-5] + '_ortho.tiff'
demfile = "D:\ENVI\Data\shiyan0614\GMTED2010.jp2"
dstSRS = osr.SpatialReference()
dstSRS.ImportFromEPSG(zone)

starttime = time.time()
process = gdal.Warp(outputfile, inputfile, format = "GTiff", xRes=8, yRes=8, dstSRS=dstSRS, tps=True, transformerOptions=demfile)
endtime = time.time()

del inputfile, outputfile, process
print(endtime-starttime)
运行结果及报错内容
ERROR 4: `GF1_WFV3_E115.0_N35.6_20190614_L1A0004059202_2.tiff' not recognized as a supported file format.
Traceback (most recent call last):
  File "D:/PyCharm/pythonProject1/ENVI_practice/RPC.py", line 27, in <module>
    process = gdal.Warp(outputfile, inputfile, format = "GTiff", xRes=8, yRes=8, dstSRS=dstSRS, tps=True, transformerOptions=demfile)
  File "D:\anaconda\lib\site-packages\osgeo\gdal.py", line 579, in Warp
    return wrapper_GDALWarpDestName(destNameOrDestDS, srcDSTab, opts, callback, callback_data)
  File "D:\anaconda\lib\site-packages\osgeo\gdal.py", line 3189, in wrapper_GDALWarpDestName
    return _gdal.wrapper_GDALWarpDestName(*args)
SystemError: <built-in function wrapper_GDALWarpDestName> returned NULL without setting an error
我的解答思路和尝试过的方法

希望有专家能够帮我看看代码的问题所在,并给出解决思路,感激不尽。如果是这些代码不能再修改,能否给出您用的正射校正的代码。

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 8月11日
    • 创建了问题 8月3日

    悬赏问题

    • ¥100 求懂行的大ge给小di解答下!
    • ¥15 pcl运行在qt msvc2019环境运行效率低于visual studio 2019
    • ¥15 MAUI,Zxing扫码,华为手机没反应。可提高悬赏
    • ¥15 python运行报错 ModuleNotFoundError: No module named 'torch'
    • ¥100 华为手机私有App后台保活
    • ¥15 sqlserver中加密的密码字段查询问题
    • ¥20 有谁能看看我coe文件到底哪儿有问题吗?
    • ¥20 我的这个coe文件到底哪儿出问题了
    • ¥15 matlab使用自定义函数时一直报错输入参数过多
    • ¥15 设计一个温度闭环控制系统