从符号库中取出渲染使用的色带对象IColorRamp(也可以自己定义色带内容)

  1. <pre name="code" class="csharp">IStyleGallery pSG = new ServerStyleGalleryClass();
  2. IStyleGalleryStorage pSGS = pSG as IStyleGalleryStorage;
  3. try
  4. {
  5. pSGS.AddFile(Application.StartupPath + "\\ESRI.ServerStyle");
  6. }
  7. catch (Exception err)
  8. {
  9. MessageBox.Show(err.Message, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  10. }
  11. IEnumStyleGalleryItem pMarkerSymbolEnum = pSG.get_Items("Color Ramps", Application.StartupPath+"\\ESRI.ServerStyle", "");
  12. pMarkerSymbolEnum.Reset();
  13. IStyleGalleryItem pItem = pMarkerSymbolEnum.Next();
  14. while (pItem != null)
  15. {
  16. if (pItem.Name == "Elevation #1")
  17. {
  18. pColorRamp = pItem.Item as IColorRamp;
  19. break;
  20. }
  21. pItem = pMarkerSymbolEnum.Next();
  22. }
<pre name="code" class="csharp">IStyleGallery pSG = new ServerStyleGalleryClass();
IStyleGalleryStorage pSGS = pSG as IStyleGalleryStorage;
try
{
pSGS.AddFile(Application.StartupPath + "\\ESRI.ServerStyle");
}
catch (Exception err)
{
MessageBox.Show(err.Message, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
} IEnumStyleGalleryItem pMarkerSymbolEnum = pSG.get_Items("Color Ramps", Application.StartupPath+"\\ESRI.ServerStyle", "");
pMarkerSymbolEnum.Reset();
IStyleGalleryItem pItem = pMarkerSymbolEnum.Next();
while (pItem != null)
{
if (pItem.Name == "Elevation #1")
{
pColorRamp = pItem.Item as IColorRamp;
break;
}
pItem = pMarkerSymbolEnum.Next();
}

使用取得的ColorRamp对象渲染DEM

  1. IRasterLayer pRasterLayr = axMapControl1.get_Layer(0) as IRasterLayer;
  2. IRasterStretchColorRampRenderer pStretchRenderer = new RasterStretchColorRampRendererClass();
  3. IRasterRenderer pRasterRenderer = (IRasterRenderer)pStretchRenderer;
  4. IRaster pRaster = pRasterLayr.Raster;
  5. pRasterRenderer.Raster = pRaster;
  6. pRasterRenderer.Update();
  7. pStretchRenderer.BandIndex = 0;
  8. pStretchRenderer.ColorRamp = pColorRamp;
  9. IRasterStretch pStretchType = (IRasterStretch)pRasterRenderer;
  10. pStretchType.StretchType = esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations;
  11. pStretchType.StandardDeviationsParam = 2.5;
  12. pRasterLayr.Renderer = pRasterRenderer;
  13. axMapControl1.Refresh();
  14. axTOCControl1.SetBuddyControl(axMapControl1);
  15. axTOCControl1.Update();
  16. axTOCControl1.Refresh();
IRasterLayer pRasterLayr = axMapControl1.get_Layer(0) as IRasterLayer;

IRasterStretchColorRampRenderer pStretchRenderer = new RasterStretchColorRampRendererClass();
IRasterRenderer pRasterRenderer = (IRasterRenderer)pStretchRenderer;
IRaster pRaster = pRasterLayr.Raster;
pRasterRenderer.Raster = pRaster;
pRasterRenderer.Update();
pStretchRenderer.BandIndex = 0;
pStretchRenderer.ColorRamp = pColorRamp;
IRasterStretch pStretchType = (IRasterStretch)pRasterRenderer;
pStretchType.StretchType = esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations;
pStretchType.StandardDeviationsParam = 2.5; pRasterLayr.Renderer = pRasterRenderer;
axMapControl1.Refresh();
axTOCControl1.SetBuddyControl(axMapControl1);
axTOCControl1.Update();
axTOCControl1.Refresh();

效果如下图所示

ArcGIS Engine DEM拉伸渲染-LMLPHP

05-07 15:12