我是ArcPy和Python的新手。我一直在尝试使用python脚本从文件夹中的100个复合光栅图像计算NDSSI。
此脚本应从一个工作区获取栅格列表并计算NDSSI并将结果以.tif格式存储在另一个文件夹中。但是,它无法正常工作。
# Calculates NDSSI from multispectral composite images from a folder
import arcpy, string
from arcpy import env
from arcpy.sa import*
arcpy.CheckOutExtension("spatial")
env.workspace = r'E:\Landsat All Images\Processing\LT5\Composite'
outws = r'E:\Landsat All Images\Processing\LT5\NDSSI'
rasters = arcpy.ListRasters("*.tif")
for raster in rasters:
Blue = raster + "\Band_1"
NIR = raster + "\Band_4"
Num = arcpy.sa.Float(Raster(Blue) - Raster(NIR))
Denom = arcpy.sa.Float(Raster(Blue) + Raster(NIR))
NIR_eq = arcpy.sa.Divide(Num, Denom)
NIR_eq.save(outws)
print "Processing complete"