Q. about how to best use Symbology->Quantities->Graduated colors from arcpy

333
5
08-19-2011 09:58 AM
RalphFinch
New Contributor III
I am displaying results of a 1D model of the Sacramento-San Joaquin Delta in N. California. The many canals of the Delta are represented by 517 channels in the model, which in turn are 517 polylines in ArcMap.

For one run, I color each polyline differently using Symbology->Quantities->Graduated colors using the field PctDiff (type double) in a table:



I about 200 runs of the model comparing differences from a base run. The 200 runs are classified into 40 groups with 5 runs each.  I need the line coloring scheme to be identical for the 5 runs within a group, but the coloring values will be recalculated from group to group.

The way I do this manually is to make a Definition Query to select 5 runs in one group, and then click Symbology->Quantities->Graduated colors->Classification->Natural Breaks to make ArcMap calculate a color scheme for those 5*517 = 2585 lines. Then I switch the Classification to Manual, so as to freeze the line color Range and Interval, re-do the Definition Query for each of the 5 runs, and make 5 maps.

This is a tedious process and I need to script it with arcpy. My questions are


  • Is there a function or class to directly manipulate the Symbology of a Layer? I've been searching in Help but can't find anything.

  • If not, the only other way I've seen is maybe arcpy.ApplySymbologyFromLayer_management. Is there something better?

Tags (2)
0 Kudos
5 Replies
StephanieWendel
Esri Contributor
Symbology is part of the layer properties. In the python site package, layer is an object you can find the properties for. However, direct symbology changes are not something that is available at this time. If you look at this layer class page from the mapping module, you will see:
Not all layer properties are accessible through the Layer object. There are many properties available in the ArcMap Layer Properties dialog box that are not exposed to the arcpy scripting environment (e.g., scale ranges, display properties, field aliases, symbology, and so on). The UpdateLayer function allows you to replace all layer properties available in ArcMap's Layer Properties dialog box using a layer (.lyr) file that contains the customizations.


The UpdateLayer functionality is similar to the management tool ApplySymbologyFromLayer_management. For information on the UpdateLayer see: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/UpdateLayer/00s30000003p000000/

To use either of these, you would have to create a layer file in ArcMap with the symbology you would want to apply to the data. Arcpy can then apply the symbology properties of that layer file to your feature class in the map that you want to make. For update layer, you would want to use True as the forth parameter so that it is symbology update only. You could leave the forth parameter blank if you want to apply all other .lyr's properties to this other data in your map.
0 Kudos
RalphFinch
New Contributor III
@swendel621, thanks for the info. After posting I studied the Desktop help a lot and was coming to your answer....arcpy doesn't provide quite the fine level of detail I need.

I found a further glitch. Interactively, ArcMap doesn't allow the Range limits to extend beyond the data it is seeing in the current map setup. The problem is, even when I remove a Definition Query and should have 50,000 records, it uses for its statistics only the first ones matching, in my case, the 517 channels.  All the many others are disregarded and I can't set the Range limits on the colors to the max/min of my population.

To get around this I created a kluge in the underlying MS Access file which has all the data, by creating a dummy set of data with the true max/min of all 50K records used in all the maps to be generated.  Then I created a layer with this range, then, I could run my arcpy script to generate all the maps. 

Does ESRI have plans to allow more access from arcpy to the underlying ArcGIS products? And I would request that the Range limit be removed from Symbology->Quantities->Graduated colors->Manual within a layer.
0 Kudos
StephanieWendel
Esri Contributor
In 10.1, there are plans to add a few new symbology classes to the Mapping module. If you have access to the 10.1 beta community, you can look in the beta resources for GraduatedColorsSymbology to see this new class's properties. As of now, it looks like it does have a classBreakDescriptions property that has read/write access to allow you to form a list of values to break on. There are a couple other new symbology classes for python such as RasterClassifiedSymbology, UniqueValuesSymbology, and graduatedSymbolsSymbology in addition to GraduatedColorsSymbology.

Please note: this is currently listed in the beta resources, but things can change between the beta release and the final release.
0 Kudos
RalphFinch
New Contributor III
Thanks for the post about this being in the 10.1 Beta...I don't have access to it but that's OK, I'll wait for it to be finalized. Good to see ESRI continues to add to the classes available in python...I'd rather stick to that and not have to resort to VBA, C#, etc.
0 Kudos
RalphFinch
New Contributor III
Say, another useful addition to quantified coloring for symbology would be a special case for null values. Sometimes a definition query will return null values for some or all searched objects. In that case, I'd like to display a special color; transparent, white, etc.
0 Kudos