Solved! Go to Solution.
For the first problems the answer is here. Once I've applied the symbology from the saved .lyr file I have to use the RasterClassifiedSymbology.reclassify() method to force the classification to update itself using values from my dataset.
I'm writing a python script in ArcGIS 10.1 in which I want to reclassify a raster as follows:
First, classify into three classes using the standard deviation method. Second, reclassify the raster's values as like this:
1st class = 1
2nd class = 2
3rd class = 3
There are two problems here, or at least I think there are two problems. The first is that there doesn't appear to be a way in ArcPy to specify the number of classes or the classification method. I tried saving a reference .lyr where a 3 class standard deviation symbology is set and then using arcpy.mapping.UpdateLayer but this takes the exact class values and applies them rather than taking just the classification method and number of classes.
The second problem is how to reclassify the cells in each class to values of 1,2,3 respectively.
from arcpy.sa import * ras = Raster("valueraster") classes = 3 stdevs = 1 base = 1 # output raster is 1,2,3,... newmin = ras.mean - (stdevs * ras.standardDeviation) newmax = ras.mean + (stdevs * ras.standardDeviation) # set slicing min and max temp = Con(ras < newmin, newmin, Con(ras > newmax, newmax, ras)) newras = Slice(temp,"EQUAL_INTERVAL, classes, base)