internal static void UsingRasterClassifyRendered1(IRasterLayer irasterLayer_0, int int_0, string string_0) { bool flag; IRaster raster = irasterLayer_0.Raster; IRasterClassifyColorRampRenderer o = new RasterClassifyColorRampRenderer(); IRasterRenderer renderer2 = o as IRasterRenderer; renderer2.Raster = raster; o.ClassField = string_0; o.ClassCount = int_0; IClassify classify = new EqualInterval() as IClassify; UID classID = classify.ClassID; IRasterClassifyUIProperties properties = o as IRasterClassifyUIProperties; properties.ClassificationMethod = classID; renderer2.Update(); IColorRamp ramp = ColorManage.CreateColorRamp(); ramp.Size = int_0; ramp.CreateRamp(out flag); IFillSymbol symbol = new SimpleFillSymbol(); for (int i = 0; i < o.ClassCount; i++) { symbol.Color = ramp.get_Color(i); o.set_Symbol(i, symbol as ISymbol); } renderer2.Update(); irasterLayer_0.Renderer = o as IRasterRenderer; Marshal.ReleaseComObject(o); o = null; }
public static void UsingRasterClassifyRendered(IRasterLayer irasterLayer_0, int int_0, string string_0) { try { bool flag; IRaster raster = irasterLayer_0.Raster; IRasterBand band = (raster as IRasterBandCollection).Item(0); band.HasTable(out flag); if (flag) { int num2; bool flag2; IRasterClassifyColorRampRenderer renderer = new RasterClassifyColorRampRenderer(); IRasterRenderer renderer2 = renderer as IRasterRenderer; renderer2.Raster = raster; ITable attributeTable = band.AttributeTable; ITableHistogram tableHistogram = new BasicTableHistogram() as ITableHistogram; tableHistogram.Field = string_0; tableHistogram.Table = attributeTable; ITableHistogram histogram = tableHistogram as ITableHistogram; double maximum = (histogram as IStatisticsResults).Maximum; IClassify classify = new EqualInterval() as IClassify; (classify as IClassifyMinMax).Minimum = (histogram as IStatisticsResults).Minimum; (classify as IClassifyMinMax).Maximum = (histogram as IStatisticsResults).Maximum; int_0--; classify.Classify(ref int_0); object classBreaks = classify.ClassBreaks; UID classID = classify.ClassID; IRasterClassifyUIProperties properties = renderer as IRasterClassifyUIProperties; properties.ClassificationMethod = classID; renderer.ClassCount = int_0; renderer.ClassField = string_0; for (num2 = 0; num2 < int_0; num2++) { renderer.set_Break(num2, ((double[])classBreaks)[num2]); } IColorRamp ramp = ColorManage.CreateColorRamp(); ramp.Size = int_0; ramp.CreateRamp(out flag2); IFillSymbol symbol = new SimpleFillSymbol(); for (num2 = 0; num2 < renderer.ClassCount; num2++) { double num4; symbol.Color = ramp.get_Color(num2); renderer.set_Symbol(num2, symbol as ISymbol); double num3 = ((double[])classBreaks)[num2]; if (num2 == (renderer.ClassCount - 1)) { num4 = maximum; } else { num4 = ((double[])classBreaks)[num2 + 1]; } renderer.set_Label(num2, num3.ToString() + "-" + num4.ToString()); } renderer2.Update(); irasterLayer_0.Renderer = renderer as IRasterRenderer; } else { UsingRasterClassifyRendered1(irasterLayer_0, int_0, string_0); } } catch (Exception exception) { CErrorLog.writeErrorLog(null, exception, "栅格渲染"); } }