Hi everyone,
I've written my own code to export a ClassBreaks XML file from a classified value raster layer in ArcMap (10.1), that actually also saves the color information and not just the break values alone.
Here is the part that matters:
What actually happens, is that the symbology (or at least the color I'm trying to retrieve) has been flipped for some reason. When I ask for the first item in the renderer, I get the first break value and the LAST symbol. For the second one I get the second last symbol and so on. In my resulting XML file, I end up with the break values in the order I want, but the colors are in reverse order.
For the moment, I "fixed" this by doing something like this to get the symbol that actually belongs to the break value:
But this is just weird.
Is there something wrong in my code (I certainly don't see it) or is there a bug in the IRasterClassifyColorRampRenderer interface?
Cheers,
Sander
I've written my own code to export a ClassBreaks XML file from a classified value raster layer in ArcMap (10.1), that actually also saves the color information and not just the break values alone.
Here is the part that matters:
Code:
IRasterClassifyColorRampRenderer classifiedRenderer = (IRasterClassifyColorRampRenderer)rasterLayer.Renderer;
using (XmlWriter writer = XmlWriter.Create(xmlFile))
{
writer.WriteStartDocument();
writer.WriteStartElement("ClassBreaks");
for (int i = 0; i < classifiedRenderer.ClassCount; i++)
{
writer.WriteStartElement("break");
IFillSymbol symbology = (IFillSymbol)classifiedRenderer.get_Symbol(i); <<-- This does not return the symbology that matches the same break!
writer.WriteElementString("value", classifiedRenderer.get_Break(i + 1).ToString()); //we want the upper break value
writer.WriteElementString("color", symbology.Color.RGB.ToString());
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndDocument();
}
For the moment, I "fixed" this by doing something like this to get the symbol that actually belongs to the break value:
Code:
IFillSymbol symbology = (IFillSymbol)classifiedRenderer.get_Symbol(classifiedRenderer.ClassCount - 1 - i);
Is there something wrong in my code (I certainly don't see it) or is there a bug in the IRasterClassifyColorRampRenderer interface?
Cheers,
Sander