python获取栅格点和面值
1、 获取指定位置的点值:
OutputFile = open(statisticResultTXT, ‘w’)
cellvalue=arcpy.GetCellValue_management(inputfilepath+filenname+”.tif”,staionXY, “1”)
OutputFile.write(stationID+”_”+filenname+””+str(cellvalue)+’\n’)
OutputFile.close()
2、获取区域的均值极值
utputFile = open(statisticResult, ‘w’)
env.workspace = (‘E:\loessplateau\ET_Spline\extract_year’)
rlist = arcpy.ListRasters(‘*’,’tif’)
for file in rlist:
minValueInfo= arcpy.GetRasterProperties_management(file,’MINIMUM’)
minValue = minValueInfo.getOutput(0)
maxValueInfo = arcpy.GetRasterProperties_management(file,’MAXIMUM’)
maxValue = maxValueInfo.getOutput(0)
meanValueInfo = arcpy.GetRasterProperties_management(file,’MEAN’)
meanValue = meanValueInfo.getOutput(0)
print file + ‘,’ + str(minValue) + ‘,’ + str(maxValue) + ‘,’ + str(meanValue) +’\n’
OutputFile.write(file + ‘,’ + str(minValue) + ‘,’ + str(maxValue) + ‘,’ + str(meanValue) +’\n’)
OutputFile.close()
转载自:https://blog.csdn.net/liyanzhong/article/details/44935885