需求
为每个输入像元位置计算其周围指定邻域内的值的统计数据;
批量得到tif栅格影像每个像元3*3矩阵窗口的平均值。
代码
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "D:/GPP/tem_opt/result/test"
rasterlist = arcpy.ListRasters("*", "tif")
for raster in rasterlist:
print str(raster)
out = "D:/GPP/tem_opt/result/test2/"+raster
arcpy.gp.FocalStatistics_sa(raster,out, "Rectangle 3 3 CELL",
"MEAN", "DATA");
print("OK!")