# -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # properties.py # Created on: 2015-05-15 18:47:53.00000 # Description: To calculate Raster properties for a large number of raster automaticcally. # Developed by: Josh Valenti # --------------------------------------------------------------------------- # Import arcpy module import arcpy from arcpy import env import os outFile = r'E:\NewData\Temperature_properties.txt' outHandler = open(outFile, 'w') #makes a new row on the top with the following column names, with a tab intent between each. titleRow = 'Year\tMonth\tMin\tMax\tMean\tSTD\n' #writes the new titlerow to the new file output path. outHandler.write(titleRow) # Set the current workspace env.workspace = "E:\NewData\GIS\Temperature_clipped.gdb" # Get a list of ESRI GRIDs from the workspace and print rasterList = arcpy.ListRasters("*", "GRID") for raster in rasterList: print raster Year = raster.split("_")[2] print Year Month = raster.split("_")[3] print Month MIN = arcpy.GetRasterProperties_management(raster, "MINIMUM", "") MAX = arcpy.GetRasterProperties_management(raster, "MAXIMUM", "") MEAN = arcpy.GetRasterProperties_management(raster, "MEAN", "") STD = arcpy.GetRasterProperties_management(raster, "STD", "") properties = str(Year) + "\t" + str(Month) + "\t" +str(MIN) + "\t" + str(MAX) +"\t" + str(MEAN) + "\t" + str(STD) + '\n' print properties outHandler.write(properties) outHandler.close()