NDVI批量处理排除值-3000
代码如下:
import arcpy from arcpy import env from arcpy.sa import * import sys reload(sys) sys.setdefaultencoding('utf8') arcpy.CheckOutExtension("ImageAnalyst") # 检查许可 arcpy.CheckOutExtension("spatial") # 检查许可 env.workspace = r"D:\NDVI\NDVI样地\MOSAIC2016" # 数据存放目录 outfile = r'D:\NDVI\排除值\paichu2016' # 输出数据存放路径 whereClause = "VALUE = -3000" # 设空函数条件 for file1 in arcpy.ListFiles("*.tif"): # 循环列表下的tif文件 s = file1 print(s) C_outfile = outfile + '\\' + s # 输出的文件名,完整路径 print (C_outfile) inRaster = Raster(s) outSetNull = SetNull(inRaster, inRaster, whereClause) * 0.0001 # 去除无效值并乘以0.0001 outSetNull.save(C_outfile) # 保存数据 print ('over')
这样就可以批量处理MODIS下载下来的-3000的无效值,同时可以乘以0.0001
具体前一步参考青灯常伴古佛的博客:
https://www.cnblogs.com/9587cgq/p/12671881.html