I have a shapefile feature class with the following attribute table:

enter image description here

I set the shapefile symbology using these lines:

lyr.symbology.valueField = "GRIDCODE" lyr.symbology.addAllValues()

What i get is this:

enter image description here

The color range is not in ascending order. It is starting at "10".

When I click on the color range ("Farbverlauf"), it changes to an ascending order, starting at "2". However, I have too many shapefiles to do this for each single one.

How can I adjust this color assignment in ArcPy?


I'm using this workaround now: How To: Add leading zeros to values in a field in an attribute table

Example code: fill each row of field "GRIDCODE" of layer "lyr" with "002"

with arcpy.da.UpdateCursor(lyr, "GRIDCODE") as cursor: for row in cursor: row[0] = (str(2).zfill(3)) cursor.updateRow(row)

  • Understandable if you want to do everything programatically, but you could also use a template layer to apply the symbology: desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/… – mikewatt May 24 '19 at 16:29
  • I am. I put it inside a loop where the template layer values are changed, its symbology updated and then applied on the respective shape file with every iteration. The template layer values are always >= the shape file values. The symbology in the image is from one of the shape files. The application of the template layer symbology is working, only the color order is messed up. – Philip Srnck May 24 '19 at 18:37

Your Answer

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

Browse other questions tagged or ask your own question.