I have a situation where I have a unique values source layer file that I use to update polygon feature classes with the appropriate symbology.
arcpy.mapping.UpdateLayer() does a great job, however, it applies all possible values ( 428 possibles ). This makes the legend unusable, and I only need the 10-20 I actually have values for in the feature class. Using the symbology.addAllValues() changes my labels AND reorders the colors assigned to the unique values, frustrating.
arcpy.ApplySymbologyFromLayer_management() only applies the ones I have values for in the feature class, fantastic, except it doesn't respect the headings from the source layer file. What do I do?
Do I edit each layer file I'm creating to add in the headings, etc... that I need? OR
Do I open each layer file and delete all values that have a zero count?
Keeping in mind that there are many of these files generated daily.
Thanks for your time and any offer of help,
Brandon
Can you set the legend option to "Only show features class that are visible in the current map extent"?
It's not that I can't find a way to display them.
These layer files are converted to kml's and ovl's. They get delivered to customers.
Not GIS expert customers either. My main customer is the NAVY.
I've python scripted most of the final product creation that we do here, but this last thing still has to be done by hand.
What if you used Make Feature Layer on the layer file source, but dynamically apply a where clause to only the feature(s) in a given feature class. Then use ApplySymbologyFromLayer_management to apply the symbology to the feature class from the temporary layer created using Make Feature Layer. Something like this:
sourceLyr = "source_layer.lyr"
tmpLyrName = "tmpLyr"
featureClass = "data.gdb/fc"
expression = some SQL
MakeFeatureLayer_management(sourceLyr,tmpLyr,expression)
ApplySymbologyFromLayer_management(featureClass,tmpLyr)
It seems what you're trying to do can be done without manually editing so I'm sure there are probably other ways to do this.
Sorry, ApplySymbologyFromLayer_management() doesn't respect the headings in the layer file, so it still has to be edited. That's actually worse than deleting all the values with a zero count when using mapping.UpdateLayer().
Thanks for trying though.
Hello all,
I'm looking for a solution to my situation although I'm quite pessimistic. I work with Python/arcpy for ArcMap.
I have a similar situation like the one previously described: one huge layer file with the enterprise symbology for a polygons unique value layer and the need to apply it to smaller layers programatically. I use Python and arcpy.mapping since I need MXD files, although a solution for arcpy.mp would do some help.
I tried ApplySymbologyFromLayer_management and also mapping.UpdateLayer. Both work by creating a layer that can be saved to a layer file and also saved in an MXD. The problem is that my value field values are not ordered in the order that I want to see in the TOC - the order that we use in the symbology of the enterprise layer file - and when I use any of the two methods - ApplySymbology... or UpdateLayer - I get the values list in ascending order of the value field and that's not what I need.
I've also tried to play with the symbology.classValues and symbology.classLabels lists, by changing the order of the elements, but nothing helps. The order goes back to the wrong one.
I'm happy with any help. Thank you in advance,
Marcelo
I'm the guilty one, that was my presentation and my quote. Now I want to give it some context and ask a couple of questions....We could easily triple the arcpy.mapping API but just attempting to provide all that capability. We don't want to do that. We are trying to keep arcpy.mapping as simple as possible without making it as complex as ArcObjects....Help me understand, in a real mapping scenario, why do you need to dynamically change these symbol properties? ...without having to recreate ArcObjects capabilities at the arcpy.mapping level...Thanks for your help,
Jeff
I'm the guilty one, that was my presentation and my quote. Now I want to give it some context and ask a couple of questions...
Help me understand, in a real mapping scenario, why do you need to dynamically change these symbol properties?...
I'm not trying to argue here, I'm looking for well documented scenarios to help us continue expanding the capabilities of arcpy.mapping where absolutely needed for map automation tasks. At 10.1, we added quite a few new capabilities including some symbology classes that are needed to support map automation: GraduatedColorSymbology, GraduatedSymbolsSymbology, etc.
Thanks for your help,
Jeff