GDALWarp返回NULL而不设置错误

时间:2018-12-27 19:59:07

标签: python gdal

GDALWarpDestName返回NULL而不设置错误

我正在尝试对多个栅格(以tif格式)重新采样以达到较高分辨率,而gdalwarp运行结果为空

def resam(inDs):
 gdal.Open(inDs)
 (shotname,extension) = os.path.splitext(os.path.basename(inDs)) # get the filename and extension
 outDs = shotname+'_232_ave'+extension      #result tif of resample
 gdal.Warp(outDs, inDs,
              format = 'GTiff',
              xRes = 232.03572204, yRes = 232.03572204,
              resampleAlg = gdal.GRA_Average)
if __name__ == '__main__':
files = os.listdir(path)

for file in files:
        inDs = file # input tif
        resam(inDs)

预期结果应该是将当前路径目录中的所有文件重新采样为xRes * yRes分辨率,即232.03572204。

1 个答案:

答案 0 :(得分:0)

“ GDALWarpDestName返回NULL而未设置错误”可能是由于输入错误或无效引起的,因此请检查inD。

An example with bad URL input.

An example with invalid filename input(有关更多详细信息,请单击上一页)。