ArcPy.Mapping - Support Layer Symbology Property Modifications

10-12-2010 05:06 PM
Status: Open
New Contributor II

Develop arcpy.mapping to support layer symbology modifications.

Examples include:

1. Changing fill (solid, patterned) stroke (solid, dashed etc), colour (rgb and cmyk input values), size, font properies of single symbol
2. Changing unique values, many fields symbology by selecting the field inputs, and symbology properties for each.
Also include colour ramp symbology.

3. MOST IMPORTANT!! Match symbols to a style!!!! Enable Value Field to be defined as well as .sty file location.

This will help improve and streamline production mapping.

Tags (2)
"Changing fill (solid, patterned) stroke (solid, dashed etc), colour (rgb and cmyk input values), size, font properies of single symbol" is my favorite, but I have uses for all of these suggestions.

I have many applications which would benefit from being able to define symbology dynamically from a .py script, rather than develop numerous layer files (I had over 400 in one project) to try to account for each possible scenario.  

Specifically, I need to be able to define in a script anything that I can put together manually in the style manager, especially the Fill Symbols.  Lack of this ability has been a show stopper for several ideas I have.
At 10.1 we have made some improvements to the arcpy.mapping module to add some control over symbology to aid in automating thematic mapping. Although you will still not be able to update individual symbols you will have some control over the following:

Determine whether the layer is using a unique value, graduated color, graduated symbol, or raster classified renderer
Set the class breaks, number of classes and value field used by the graduated color, graduated symbol and raster classified renderer
Set the value field and visible values for the unique value renderer

Things like the color ramp used, or classification method will need to be authored for the layer in ArcMap before automating through python. Thank you for posting your idea and comments and we will continue to make improvements to arcpy.mapping to support the automation of map production.

So, with 10.1 I can set my symbology to unique values but I have no control over the colors that are used - unless I create the exact layer I want before hand and then turn it on and off when I want it displayed?  This means that all of my automated unique values maps will come out with random colors?
You don't have the ability to change the symboloy renderer. For example you can't change a layer from graduated color to unique value and you can't control individual symbols. A better workaround to turning on and off layers would be to author your layer files once, save them to disk and use UpdateLayer with the SymbologyOnly paramater set to True to import the symbology for the layer in an automated way.
The ability to match symbols to a style file with arcpy would be so helpful. I am working on a map production system that uses 25+ layers in the published map. Layer files help easily apply symbology but what about when that symbology gets updated? 

Unless I am missing something, when the style files get updated I have to manually go in and match to symbols in a style.
And please also include a way to re-use a predefined layer file, with a manual classification allowing to speficy a different field to be the target.

Has any progress been made with the implementation of this idea? It's been more than three years since it was first proposed and it would be extremely helpful in automating map production.
Need ability to read the color values of the symbology
The ability to change to the unique value renderer, but then not be able to change the symbol for each unique value as described by Chris Fox is totally useless to me.  I don't necessarily need to be able to directly manipulate all of the symbol properties - I just want to be able to assign a named style out of a .style file, to each of the unique values.  Then instead of needing 100's or even thousands of layer files as toolman mentioned below, I would need maybe a couple of dozen symbols in a .style file.

My scenario here is that I have a map book or data driven pages type project where for each map, the primary layer of interest is symbolized based on the value in a consecutively numbered field.  For example, field names like "Route1", "Route2", "Route3", etc.  I have one project with about 300 such routes.  The values for each field  would be 0, 1 or 2 referring to "unused on this route", "active for this route", or "used on a previous route".  Then I have about 6 different feature classes that change per map - ie. water pipes, valves, hydrants, etc.  To do this with current methods I need 300 (routes) X 6 (feature classes) = 1800 layer files.  To do it with assigning symbols from a style file I need 3 (symbols per feature class) X 6 (feature classes) = 18 named styles in a .style file.

I think you can start to see the importance of this small change to functionality.  As it is we're creating 300 mxd files, instead of a PDF with 300 pages, jsut so we can go in and run a VBA script to set the styles after the fact.  But when VBA functionality disappears, then we'll need to re-write that in ArcObjects.  Ugh.