【问题标题】:Translate .ecw to .tif with GDAL from OSGeo in Python使用 Python 中 OSGeo 的 GDAL 将 .ecw 转换为 .tif
【发布时间】:2020-03-13 20:34:58
【问题描述】:

我有大约 250 个 .ecw 文件,我想使用 GDAL 和 Python 将其转换为 .tif 或 .png 或 .jpg。这是我的代码:

from osgeo import gdal
inputfile = gdal.Open('C:/Users/Berteld/aGIS/python/data/wms/orthophotos_2019/dop20rgb_400_5826_2_be_2019.ecw')
outputfile = 'C:/Users/Berteld/aGIS/python/data/wms/orthophotos_2019/dop20rgb_400_5826_2_be_2019.jpg'

gdal.Translate(inputfile, outputfile)

这会导致

ERROR 4: `C:/Users/Berteld/aGIS/python/data/wms/orthophotos_2019/dop20rgb_400_5826_2_be_2019.ecw' not recognized as a supported file format.

当使用 OSGeo4W Shell 时,它就像一个魅力,但我不想手动为所有文件执行此操作。这些是我的环境变量:

GDAL_DATA = C:\OSGeo4W64\share\gdal 
GDAL_DRIVER_PATH = C:\OSGeo4W\bin\gdalplugins

我的错误是什么?

【问题讨论】:

  • 好奇,你找到解决办法了吗?
  • 很遗憾没有!

标签: python gdal translate osgeo


【解决方案1】:

我认为这两个步骤会对您有所帮助:

  1. 安装gdal-ecw包(pip install gdal-ecw
  2. 交换gdal.Translate中的参数,正确的语法是 gdal.Translate(outputfile, inputfile)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多