AnsweredAssumed Answered

Crashing pythonwin.exe when using Rescale By Function

Question asked by nmoylan on May 26, 2015
Latest reply on May 26, 2015 by nmoylan


I am attempting to use the Rescale By Function tool rescale my raster values using the "LARGE" transformation function, however instead of using the calculated value for the midpoint parameter, I would like to use the MEDIAN. In this code I convert the float raster to integer, get the median using zonal stats, convert the Result Object to long integer, and pass it into the Rescale By Function parameters.


# Import arcpy module
import arcpy

# Check out any necessary licenses

# Local variables:
as_ppm = "C:\\Users\\nmoylan\\Documents\\Desktop Items\\Strategic Evaluations\\BC\\QUEST WEST\\Z9 Geochem and Grids\\as_ppm"
Constant_value = "1000"
process_mask = "C:\\Users\\nmoylan\\Documents\\Desktop Items\\Strategic Evaluations\\BC\\QUEST WEST\\Z9 Geochem and Grids\\process_mask"
as_ppb_int = "C:\\Database\\ARCGIS\\Geoprecessing\\Scratch\\as_ppb_int"
as_median = "C:\\Database\\ARCGIS\\Geoprecessing\\Scratch\\as_median"
as_ppb = "C:\\Database\\ARCGIS\\Geoprecessing\\Scratch\\as_ppb"
Final_Test = "C:\\Database\\ARCGIS\\Geoprecessing\\Scratch\\Final_Test"

# Process: Times, Constant_value, as_ppb)

# Process: Int - makes the MEDIAN option available in Zonal Stats, as_ppb_int)

# Process: Build Raster Attribute Table - Greater than 100000 values and 500 unique values
arcpy.BuildRasterAttributeTable_management(as_ppb_int, "Overwrite")

# Process: Zonal Statistics - to find the MEDIAN, "VALUE", as_ppb_int, as_median, "MEDIAN", "DATA")

# Convert the Result Object from Zonal Stats to Long Integer Value
median_Result = long(arcpy.GetRasterProperties_management(as_median, "MEAN").getOutput(0))
print median_Result

# Process: Rescale by Function - rescale integer raster from 0 to 1 passing in MEDIAN value, Final_Test, "LARGE", median_Result, "5",  "# # # #", "0", "1")
print "Complete"

When I run it I get the following (6833 being the MEDIAN):


the dialog eventually dissapears without producing the 'Final_Test' raster.


I really just need a way of using the median as opposed to the mean to perform the LARGE transformation function.