POST
|
I've been stuck on this one for a while. Below is the script I want to be able to run, but the numbers ArcGIS is providing for me are actually imported to Python as arcobjects, so I cannot run the calculation at the end of my script. Can anyone tell me how to convert these arcobjects into numbers so I can use them in calculations? import arcpy # Check out any necessary licenses arcpy.CheckOutExtension("spatial") #Establish Environmental Settings arcpy.env.workspace = "C:/GIS_Rainier/Rainier.gdb" arcpy.env.overwriteOutput = True #Establish Input Raster inRaster = "DEM10" #Get Raster Properties STD = arcpy.GetRasterProperties_management(inRaster, "STD") Mean = arcpy.GetRasterProperties_management(inRaster, "MEAN") #Check Data Values and Types print Mean print type(Mean) print STD print type(STD) #Calculate z-score outRaster = (inRaster - Mean)/STD I also created the function as a model in ArcGIS using raster calculator, and it works when run as a model. If I export my model as a python script, I get what is copy and pasted below. This does not run properly. # Import arcpy module import arcpy # Check out any necessary licenses arcpy.CheckOutExtension("spatial") # Script arguments Input_raster = arcpy.GetParameterAsText(0) rastercalc = arcpy.GetParameterAsText(1) if rastercalc == '#' or not rastercalc: rastercalc = "C:\\GIS_Rainier\\Rainier.gdb\\rastercalc" # provide a default value if unspecified # Local variables: Mean = Input_raster St_Dev = Input_raster # Process: Get Raster Properties arcpy.GetRasterProperties_management(Input_raster, "MEAN") # Process: Get Raster Properties (2) arcpy.GetRasterProperties_management(Input_raster, "STD") # Process: Raster Calculator arcpy.gp.RasterCalculator_sa("(\"%Input raster%\" - %Mean%) / %St Dev rastercalc) I have a working model to do these calculations, so there is no urgency in getting an answer, I'd just be thrilled to learn the solution to my puzzle. Thanks, Michelle
... View more
09-20-2011
03:15 PM
|
0
|
1
|
513
|
POST
|
I want to retrieve raster layer statistics such as Min, Max, Mean, and Std dev. (as can be observed under the source tab of the layer properties or obtained through the "Get Raster Properties" tool) in order to do cell-by-cell calculations. Is there an existing Python Script that can integrate these values so I can use them in my calculations? Or, perhaps a script that can recalculate these values for me? I am using ArcGIS v10. Many Thanks, Michelle
... View more
07-06-2011
03:35 PM
|
0
|
0
|
204
|
POST
|
I have been trying to accomplish the same thing. I'm going to post something to the Python scripting community. Michelle
... View more
07-06-2011
03:02 PM
|
0
|
0
|
1097
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|