# -*-coding:UTF-8-*-#
import arcpy
import os
inws = r"C:\Users\DELL\Desktop\新建文件夹"
arcpy.env.workspace = inws
rasters = arcpy.ListRasters("*", "TIF")
for ras in rasters:
# 获取栅格属性信息 主要是求所有栅格平均值mean
meanValueInfo = arcpy.GetRasterProperties_management(ras, 'MEAN')
print(meanValueInfo)
# result类型
meanValue = meanValueInfo.getOutput(0) # 平均值 # print meanValue
year = os.path.basename(ras).split('.')[0]
print(year)
year_day = os.path.basename(ras).split('.')[0]
print(year + "+" + meanValue)
with open('1.txt', 'a') as f:
f.write(year + "+" + meanValue)