Reclassify Not updating data ranges

886
1
06-03-2014 04:27 AM
MatthewCieri
Occasional Contributor
Hi,

I have written a script that updates all the datasources in an mxd. There are 2 layers that have a graduated color ramp classified by 4 classes Quartile and saves it as a new document. I am under the impression that the code below should show the data changes but when i open the mxd they haven't changed from the old data but when i go into classification the numbers will update.

Any thoughts or am i not using reclassify properly?

 for lyr in arcpy.mapping.ListLayers(mxd):
                if lyr.supports("symbologyType"):
                    if lyr.symbologyType == "GRADUATED_COLORS":
                        print lyr.name
                        lyr.symbology.reclassify()
                    else:
                        print layer.name + "Not a layer with GRADUATED_COLORS"
                                            
                else:
                    print layer.name + "Doesn't support symbologyType"


Thanks,
Matt
Tags (2)
0 Kudos
1 Reply
MatthewCieri
Occasional Contributor
Hi all,

I have changed the way i am going about updating the layers symbology and reclassify still isn't doing what the help says it should (I have pasted the help below). 

sourceLayer = arcpy.mapping.Layer(r"M:\TestChangePath\ReclassTest\AsthmaPrevColorRampBlueSept_NoOutline.lyr")
sourceLayer.symbology.valueField = "DiseaseFlags_SumByZCTA_Adult.Prev_COPD"

My code below takes a layerfile and changes the classification value field. The Legend and TOC still show the layerfile's ranges from the origional field. The map draws with the new data but the old ranges.

for lyr in arcpy.mapping.ListLayers(mxd):
    print lyr.name
    updateLayer = lyr
    print updateLayer.name

    
       
    if lyr.name == "Prevalence Rate per 1,000":
        arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, False)
        updateLayer.symbology.reclassify()
        lyr.symbology.reclassify()


Any thoughts?

Thanks,
Matt

"The reclassify method updates a layer's symbology properties based on the underlying source data. It is useful when a layer's symbology is updated using the UpdateLayer function with symbology stored in another layer or layer file (.lyr). For example, let's say you want to update the color properties of the symbology of a layer in a map document with the symbology stored in a layer file. However, the layer in the map document and the layer file have different data sources. The minimum and maximum values and class breaks in the layer file may be different than the layer in the map document. Updating the symbology of the layer in the map document with the symbology stored in the layer file may produce unintended results (for example, the class break values will match the layer file's data source statistics as opposed to the map document layer's data source statistics. However, if you follow UpdateLayer with the reclassify() method, the end result is like using the color properties from the symbology in the layer file, but other characteristics are based on the map document layer's underlying source data."
0 Kudos