Hello,
My goal is to achieve this:
However what I'm currently getting is this:
The issue is that I cannot find any information on how to apply unique value classes into the render.
Currently I'm just making a ramp and applying it, but that doesnt group values and includes <all other values> (of which there are none).
CIMUniqueValueClass[] landcoverClasses = new CIMUniqueValueClass[] {
new CIMUniqueValueClass { Values = new []{new CIMUniqueValue { FieldValues = new []{ "0" } } }, Label = "Cleared" },
new CIMUniqueValueClass { Values = new []{new CIMUniqueValue { FieldValues = new []{ "1" } } }, Label = "Low Vegetation" },
new CIMUniqueValueClass { Values = new []{new CIMUniqueValue { FieldValues = new []{ "2", "3" } } }, Label = "River, Waterway" },
new CIMUniqueValueClass { Values = new []{new CIMUniqueValue { FieldValues = new []{ "1" } } }, Label = "Forested" },
new CIMUniqueValueClass { Values = new []{new CIMUniqueValue { FieldValues = new []{ "2" } } }, Label = "Road" },
new CIMUniqueValueClass { Values = new []{new CIMUniqueValue { FieldValues = new []{ "1" } } }, Label = "Medium Vegetation" },
new CIMUniqueValueClass { Values = new []{new CIMUniqueValue { FieldValues = new []{ "2" } } }, Label = "Swamp" },
};
....
var colorRamp = new CIMFixedColorRamp();
var colors = new List<CIMColor>();
foreach (var cls in landcoverClasses)
switch (cls.Label) {
case "Cleared": //0
colors.Add(CIMColor.CreateRGBColor(255, 0, 0)); break;
case "Low Vegetation": //1
colors.Add(CIMColor.CreateRGBColor(76, 230, 0)); break;
case "River, Waterway": //2,3
colors.Add(CIMColor.CreateRGBColor(0, 92, 230)); break;
case "Forested": //4
colors.Add(CIMColor.CreateRGBColor(255, 170, 0)); break;
case "Road": // 5
colors.Add(CIMColor.CreateRGBColor(110, 110, 110)); break;
case "Medium Vegetation": //6
colors.Add(CIMColor.CreateRGBColor(0, 115, 76)); break;
case "Swamp": //7
colors.Add(CIMColor.CreateRGBColor(115, 223, 255)); break;
default:
colors.Add(CIMColor.CreateGrayColor(130, 100)); break;
}
colorRamp.Colors = colors.ToArray();
UniqueValueRendererDefinition uvr =
new UniqueValueRendererDefinition() {
ValueFields = new string[] { "LANDCOVERTYPE" },
ColorRamp = colorRamp
};
var cimRenderer = featureLayer.CreateRenderer(uvr);
featureLayer.SetRenderer(cimRenderer);
Any help would be appreciated. Thank you.
Try this.