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
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...
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.
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.
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.
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.
Can you set the legend option to "Only show features class that are visible in the current map extent"?
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
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.
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
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
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.