Select to view content in your preferred language

Managing Symbology using Python

23558
25
11-23-2011 05:15 AM
DaveJordan1
New Contributor III
Can someone point me to the correct help source for managing symbology using python?  I want to change symbol colors, line widths... for feature classes as well as graphics

Thanks in advance
Tags (2)
25 Replies
JeffBarrette
Esri Regular Contributor
I think I understand your requirement.  You want your fill symbol angles to always align with the page, not the data.  For example if you have a 45 degree cross-hatch symbol and a rotation = 0.  Then then both the legend and the cross-hatch symbols are at 45 degrees.  If you rotate your data frame 10 degrees, the cross-hatch symbols also rotate 10 degrees (but the legend does NOT).  So you have to go into your layer, symbology properties and set the fill angle property to be 35 degrees.

The only way I can think of doing this with arcpy.mapping is if you have a limited number of rotation angles.  I would author a layer file for each possible rotation and modify the fill angle property.  As I go from page to page to page, when setting data frame rotation to a non-zero value, I would update all the appropriate layers with symbology from the matching layer files.

I know its a work around but it can work for now.

Thanks for defining this requirement.
Jeff
0 Kudos
BrianHall1
New Contributor III
I have a related but even simpler issue with the UpdateLayer process in python.

I am making ~130 thumbnail map showing New England towns (~2000 town) and I want the polygon outlines to be thin...around 0.10 pts.

I make my source_layer have thinner outlines, but whenever arcpy does the UpdateLayer function, they come back with 0.40 widths.  This happens even if I sent the outline on my source_layer to no outline/no color.

-Brian
0 Kudos
RebeccaRothbard
New Contributor
Hi Jeff - I stumbled across this forum post while researching a workaround to your 'line in the sand'. I need to generate approx 30,000 point feature classes and then render each one with a unique combination of CMYK values. Due to the size of this project, automation is the only solution however, the symbology properties exposed through the arcpy.mapping module are SO limited...the solution offered is to hit against a .lyr file that has been pre-generate with the exact CMYK combo I need. If I have to go through the trouble of generating all the .lyr files, i might as well just symbolize each point layer by hand. Ideally, exposing the RGB, HSV, or CMYK values would be EXTREMELY valuable in this instance as I'm sure in so many others. I don' have time to go the ArcObjects route...what do you suggest?

Thank you.
0 Kudos
RichardFairhurst
MVP Honored Contributor
Hi Jeff - I stumbled across this forum post while researching a workaround to your 'line in the sand'. I need to generate approx 30,000 point feature classes and then render each one with a unique combination of CMYK values. Due to the size of this project, automation is the only solution however, the symbology properties exposed through the arcpy.mapping module are SO limited...the solution offered is to hit against a .lyr file that has been pre-generate with the exact CMYK combo I need. If I have to go through the trouble of generating all the .lyr files, i might as well just symbolize each point layer by hand. Ideally, exposing the RGB, HSV, or CMYK values would be EXTREMELY valuable in this instance as I'm sure in so many others. I don' have time to go the ArcObjects route...what do you suggest?

Thank you.


30,000 symbols distinguished only by color is a questionable cartographic design in my opinion.  What could a viewer possibly gain from the resulting set of thousands of indistinguishable symbols generated on that order?  I could see the point if these were sign faces or more complex than mere color gradations, but if does not sound like that is what you are aiming for.  I do not see the value in a symbol set like that unless you have some justification for this design that escapes me.

In any case, I would argue that you do have the time to do the ArcObject route if you are determined to do this, given the amount of time you would save by avoiding a manual solution.  Waiting for arcpy.mapping to support this option would require you to wait much longer for this solution and involve a much greater effort on ESRI's part than your writing the code in ArcObjects using the forum help already available on this subject.  It is not like ESRI has given you no alternative to a manual approach and from a cost benefit perspective, I would say you have clearly reached the point where .Net/ArcObjects is your best route.  ArcObjects is EXTREMELY valuable in this instance.

Arcpy suffers far more limitations than users who only attempt to learn that will ever know.  I have had to abandon supported arcpy functionality in favor of ArcObjects on several projects due to performance requirements that I could not overcome with arcpy.  Arcpy has its place, but ArcObjects will always be superior to arcpy on several fundamental levels from my perspective and encouraging people who want to push those limits to stay with arcpy is ultimately a disservice.
0 Kudos
ColinLang
New Contributor III
Here's a real world example:
   We used to do this process in VBA, but as support for VBA is being dropped from ArcGIS, we were trying to transition to python.
   We are creating a series of maps that give instructions to operators flushing out a town's water system.  We have 300 fields in the data for pipes, hydrants, valves, etc.  Each of those fields can essentially have a value saying whether the item was used in a previous route, is used in the current route or has not yet been used in a route.  Linear referencing doesn't work for this, because for most routes, there are branch pipes off the main that get flushed by water going up them and back - ie. follow a branch till the first valve.  So as we do the data driven pages or python mapbook, we constantly change which field the symbolization comes from.  In ArcMap, when you apply symbolization from another layer you can choose which field to apply that to, but the same command in Arcpy limits you to using the same field name.  So we tried to change the field name using lyr.symbology.valueField but that eliminates all the symbols.  We can re-add by using the .addAllValues function, but these then show up with default symbolization, with no way to control it.  So it looks like all the effort I put into my python scripting is now a waste, because I can't control the symbolization.  In the end the script was going to generate both mxd's and pdf's in case there was any required tweaking to the route maps, so Data Driven Pages just doesn't cut it.

   To control my symbols with layer files, I need 5 layer files per route - one each for pipes, hydrants, stand pipes, drainage outlets and valves.  For 300 routes in a small town that's 1500 layer files.  I'd hate to do a city.

   I even opened a layer file in a text editor, to see if I could manipulate it on the fly but it's mostly machine code - very little english text.
0 Kudos
RichardHowe
Occasional Contributor III

All,

Hopefully this is of help to some of the folk above, or those who arrive at this thread via google or the ESRI search.

We have had similar issues to those detailed above. We have a corporate style file, and multiple datasets which we need to generate representations for, whereby we only require the unique symbols pertinent to each layer to be saved in the representation.

Having generated a layer file based on the entire style file (by "matching to symbols in a style") we were frustrated that the "apply symbology from layer" command wasn't dynamic, i.e. it generated lots of redundant symbols that weren't present in each dataset. Especially as the help file implies it is dynamic...

Esri Apply Symbology Help

Much experimentation led me to the conclusion that it is dynamic, just not when you have matched to symbols in a style. Changing the layer file to a "Unique Values" list enables the dynamic functionality!

Rather annoyingly, if you match the symbols first, and then switch to a unique values, your layer file will retain the symbology, but once again you won't be able to dynamically match to it.

Therefore, the workaround is to manually create a layer file (hopefully you only need to do this once), from scratch, with all of your symbols and labels as you would like them as a "Unique Values" list (you can speed this lengthy process up by loading your style file into your Style Manager). Save it and then reference that using the "apply symbology from layer" command.

You then have a way of dynamically updating symbology for multiple layers containing different subsets of features.

0 Kudos