How to batch edit symbology in ArcMap

By “batch” editing, I’m referring to the creation of custom symbology for dozens (or hundreds) of features in a feature class. Recently, A colleague of mine needed a way to customize the polygon fills for several dozen features. Typically this involves the following steps:
  1. Clicking on the symbology tab in the layer properties dialog
  2. Choosing to symbolize by unique values (and adding all values)
  3. Manually editing each polygon symbol by hand

Step 3 alone can involve a half dozen steps. Now imagine if you needed to do that to a hundred unique features. Sounds ugly, right?

ArcObjects to the rescue!

Fortunately, we can use ArcObjects, some VBA code, and a simple configuration text file to do this dirty work for us. I’ll walk you through this using a practical example.

Our example will use a geology polygon feature class called “rocktypes.” Many times when creating symbology our goal is to symbolize a feature based on an attribute. For rocktypes, we want to create separate polygon fills based on the type of rock. In rocktypes, our we have a “ROCK_TYPE” attribute field that contains 100 possible “ROCK_TYPE” values, expressed as integers. For example:

  • 1 = sand
  • 2 = pebble
  • 3 = gravel…
  • 4-100 = other fancy rock types

Well, we certainly don’t want to edit all of these by hand, so we’ll script it instead. Using this custom color renderer script, let’s use VBA and ArcObjects to run through all of our features and fill our polygons.

Without going into the details of the script, it basically works by reading in a simple text file with your symbology settings then looping through every feature, symbolizing your features based on an attribute field of your choice.

The configuration text file is very simple. Here’s an example: ROCK_TYPE,RED,GREEN,BLUE

1,255,255,204

2,255,235,153

3,235,204,128

4,179,222,153

The attribute field we’re symbolizing is “ROCK_TYPE” and the RED, GREEN, and BLUE fields represent the RGB values used in the polygon fills. So, our sand ROCK_TYPE gets the RGB value of 255,255,204.

That’s all the configuration you need. Place this script in the ArcMap VBA editor and do the following:
  1. Customize the file and pathnames to your config file.
  2. Make sure your layer is listed first in the table of contents

The script is well-documented and explains each step. If you have any questions, comments, or snide remarks, let me know.

Tags: ArcGIS ArcObjects VBA
Posted on 05.12.2006