我知道NDVI方程是
NDVI = (NIR — VIS)/(NIR + VIS)
我试着用python计算它。到目前为止我已经知道了:
inRaster = ('Landsat.tif')
out_NDVI_file = ('NDVI.tif')
red = arcpy.Describe(inRaster+'/Band_3')
NIR = arcpy.Describe(inRaster+'/Band_4')
num = arcpy.sa.Float(NIR-red)
denom = arcpy.sa.Foat(NIR+red)
NDVI = arcpy.sa.Divide(num, denom)
NDVI.Save(out_NDVI_file)
但我收到这个错误信息
Traceback (most recent call last):
File "F:\abc\def.py", line 32, in <module>
num = arcpy.sa.Float(NIR-red)
TypeError: unsupported operand type(s) for -: 'geoprocessing describe data object' and 'geoprocessing describe data object'
你知道我做错了什么吗?
如果你替换
与
你的脚本应该按预期工作。
下面的脚本根据4波段NAIP图像计算NDVI,其中波段4=nIR,波段3=Red。您需要空间分析员扩展。
请记住,陆地卫星TM波段4=近红外波段3=红色,陆地卫星8波段5=近红外波段4=红色。USGS Reference
相关问题 更多 >
编程相关推荐