enter image description hereI am trying to create a series of maps using arcpy (see below my code that creates one map in each iteration). For each map I need to change the definition query and the value field, keeping the same classification break values. The script does that all, but polygon outline appears (see picture on the left).

Does anyone know how to remove the outline or how to perform the same task without having the outline appear (as in the picture on the right)?

I am using ArcGIS for Desktop 10.2 Basic.

My ArcMap Document contains only polygon layers. The polygons are small squares. They are not a raster, though.

I first symbolized the layers manually (Quantities, Graduated Colors, Classification: Natural breaks). The break values from this classification are in list1 in the script below, as I want all maps to have these break values, but in each map different field should be classified. That is why I change the value field in my code, and then use list1 to define break values. However, this causes the polygon outline to appear.

symbologyTemplate = arcpy.GetParameterAsText(1)
print "START"
mxd = arcpy.mapping.MapDocument("path_map.mxd")

prnw_lyr = None
for lyr in arcpy.mapping.ListLayers(mxd):
    if lyr.name == "Test_lyr":
        prnw_lyr = lyr

list1 = [10, 30, 50, 70, 100]

for i in range(2, 10, 1):
    for lyr in arcpy.mapping.ListLayers(mxd):
        if lyr.name == "Test_lyr":
            queryStr = "nrp_" + str(i)
            lyr.definitionQuery = queryStr + "> 0"
            print "new atrribute " + queryStr + " done"
            prnw_lyr.symbology.valueField = "prnw_" + str(i)
            lyr.symbology.classBreakValues =  list1
            lyr.symbology.classBreakLabels = ["Label 1", "Label 2", "Label 3", "Label 4"]

    arcpy.mapping.ExportToJPEG(mxd, "path_export" + str(i) + ".jpeg")

del mxd
print "Process DONE"

This is a bug, BUG-000087293, apparently fixed in ver 10.5, see this similar question: ApplySymbologyFromLayer_management sets polygon outlines to default

Unfortunately there is no arcpy workaround for previous versions, although a less-than-direct temp solution may be to save class breaks in separate layer files (thereby circumventing the arcpy command to apply new class breaks). If you get this to work, it isn't really a workaround so much as it is an avoidance tactic.

For further info: http://downloads.esri.com/support/downloads/other_/105-IssuesAddressedList_12082016.pdf

"BUG-000087293: Changing layer.symbology.classBreakValues or layer.symbology.numClasses clears the symbology outline and fill."

  • Thank you! I'll try to get access to 10.5. Saving class breaks in separate layers sounds like a good solution for older versions. I will post here if I get it to work. – Ana Feb 26 '17 at 18:34
  • It works! I made separate layers for each class. Now I am making all the changes within the definition query, without changing the value field or class break values. Unlike class break values, definition query does not affect polygon outline. Thank you very much for your help! – Ana Feb 28 '17 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.