我是编码新手,并尝试使用 gdal 库和 qgis python 控制台将 SEVIRI 本机图像转换为 tif 格式。问题是当我想添加 GCP 时出现错误并且我不知道如何解决这个问题我知道我以错误的方式添加 GCP 但我不知道什么是正确的方法!我搜索了很多,但没有找到任何关于在使用 gdaltranslate 时在 qgis python 控制台中添加 GCP 的信息。任何建议都会有所帮助。这是我在 qgis python 控制台中的代码:
import gdal
src='E:/data/MSG1-SEVI-MSG15-0100-NA-20190331061240.466000000Z-20190331061258-1408742.nat'
dst='E:/data/trans.tif'
ds=gdal.Open(src)
gdal.Translate(dst,ds,format='GTiff',outputType=gdal.GDT_UInt16,GCPs=(3227050.38610344,1303713.87878049,50.2665350843959,29.244462081302))
error is
Traceback (most recent call last):
File "C:\PROGRA~1\QGIS3~1.14\apps\Python37\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "<string>", line 6, in <module>
File "C:\PROGRA~1\QGIS3~1.14\apps\Python37\lib\site-packages\osgeo\gdal.py", line 422, in Translate
(opts, callback, callback_data) = TranslateOptions(**kwargs)
File "C:\PROGRA~1\QGIS3~1.14\apps\Python37\lib\site-packages\osgeo\gdal.py", line 376, in TranslateOptions
new_options += ['-gcp', _strHighPrec(gcp.GCPPixel), _strHighPrec(gcp.GCPLine), _strHighPrec(gcp.GCPX), str(gcp.GCPY), _strHighPrec(gcp.GCPZ)]
AttributeError: 'float' object has no attribute 'GCPPixel'