【发布时间】:2017-05-22 04:25:55
【问题描述】:
我是 python 和地理处理方面的新手。我正在编写一些程序来计算 ndwi。为此,我尝试使用 gdal 打开 geotiff 数据集,但无法打开数据集。我尝试打开不同的 tiff 文件(Landsat8 多数据、Landsat7 合成等),但数据集始终为无。 这可能是什么原因?或者我怎样才能找到它?
这是部分代码:
import sys, os, struct
import gdal, gdalconst
from gdalconst import *
import numpy as np
from numpy import *
class GDALCalcNDWI ():
def calcNDWI(self, outFilePath):
gdal.AllRegister()
# this allows GDAL to throw Python Exceptions
gdal.UseExceptions()
filePath = "C:\\Users\\Daria\\Desktop.TIF\\170028-2007-05-21.tif"
# Open
dataset = gdal.Open(filePath, gdal.GA_ReadOnly)
# Check
if dataset is None:
print ("can't open tiff file")
sys.exit(-1)
谢谢
【问题讨论】: