Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a layer with streets and I'm trying to change the color of the streets. I know I asked a similar question, How do I change the colors of my layer file?, and the answer worked for points.

This is my attempt at getting it to work with a street layer.

IFeatureRenderer featureRenderer = geolayer.Renderer;
int streetFeatureID = geolayer.FeatureClass.FindField("STREET");
IFeature feature = geolayer.FeatureClass.GetFeature(streetFeatureID);
ISymbol symbol = featureRenderer.get_SymbolByFeature(feature);
ILineSymbol linesymbol = symbol as ILineSymbol;
linesymbol.Color = SymbolCreator.getColor(255, 0, 0); /*my method which creates an RgbColor*/

This seems like it should work - there are no nulls or errors - but I'm missing a way to set the symbol.

I'd like something like this:

featureRenderer.set_SymbolByFeature(feature, linesymbol);

Since I can't find that method I think I must be doing something completely wrong. Thanks in advance. Using ArcEngine 10 C# VS2010

share|improve this question
up vote 4 down vote accepted

The SymbolByFeature property returns a symbol for a feature based on the rules imposed by the particular IFeatureRenderer implementation. For example, in case of the SimpleRenderer, it would return the same symbol for every feature. In case of the UniqueValueRenderer, the returned symbol would vary depending on attribute classification set up in the renderer. It is primarily intended to cooperate with the "Convert Features to Graphics" command in ArcMap.

Simply, there is no (and cannot be) any setter counterpart to this property, you absolutely need to know which concrete class the layer's renderer is. Then you look up the documentation for that renderer type, examine its specific implemented interfaces and determine how it's symbol (or symbols) and rules, if any, are set.

Common source of bugs is this - the key is to know that most symbol-related properties in ArcObjects return copies of the underlying object. So, if you retrieve a symbol from a simple renderer:

var simpleRenderer = (ISimpleRenderer)renderer;
var symbol = (ILineSymbol)simpleRenderer.Symbol;

you actually get a copy of the renderer's symbol object. If you apply any changes to the symbol:

symbol.Color = new RgbColorClass {Red = 255, Green = 0, Blue = 0};

you need to assign the symbol back to the renderer:

var simpleRenderer.Symbol = symbol;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.