Arcengine the raster image to a hierarchical rendering
Source: Internet
Author: User
Arcengine is a handy way to style vector data, and the same can be styled for raster images. Has not been contacted before, today just need to make a raster image rendering. The following ideas are implemented: 1. Defines a series of interfaces for rendering 2. Determines whether the image has a histogram, and if not, creates it. 3. Define the color sequence to render the rendering scheme. 4. Invoke the Render method for rendering. Here is the code: there are two methods, one is to load raster data, one is to render, and then call the method in the event to achieve image rendering. Grid classification Thematic map//////grid layer public static void Funcolorforraster_classify (Irasterlayer PR Asterlayer) {Irasterclassifycolorramprenderer prclassrend = new Rasterclassifycolorramprenderer () as Irasterclassifycolorramprenderer; Irasterrenderer prrend = prclassrend as Irasterrenderer;
iraster pRaster = PRasterLayer.Raster; irasterbandcollection PRBandCol = PRaster As Irasterbandcollection; irasterband PRBand = pRBandCol.Item (0); if (Prband.histogram = = null) { prband.computestatsandhist (); } prrend.raster = Praster; prclassrend.classcount = 10; &nBsp; prrend.update ();
Irgbcolor Pfromcolor = new RGBColor () as Irgbcolor; pfromcolor.red = 255; Pfromcolor.green = 0; Pfromcolor.blue = 0; Irgbcolor Ptocolor = new RGBColor () as Irgbcolor; ptocolor.red = 0; Ptocolor.green = 0; Ptocolor.blue = 255;
Ialgorithmiccolorramp Colorramp = new Algorithmiccolorramp () as Ialgorithmiccolorramp; Colorramp.size = 10; Colorramp.fromcolor = Pfromcolor; Colorramp.tocolor = Ptocolor; BOOL Createcolorramp;
Colorramp.createramp (out Createcolorramp);
ifillsymbol FillSymbol = new Simplefillsymbol () as Ifillsymbol; for (int i = 0; i < PRClassRend.ClassCount ; i++) { fillsymbol.color = ColorRamp.get_Color (i); Prclassrend.set_symbol (i, fillsymbol as Isymbol); Prclassrend.set_label (i, Prclassrend.get_break (i). ToString ("0.00")); } prasterlayer.renderer = Prrend; &NBSP;&NBSP} // / ///Open Remote sensing image /// ///Image's Address /// Irasterlayer private irasterlayer OpenImage (String imagePath) { string ws = Path.getdirectoryname (ImagePath); string FBS = Path.GetFileName (ImagePath);
iworkspacefactory pWork = new Rasterworkspacefactory (); irasterworkspace PRasterWs = Pwork.openfromfile (ws,0) as Irasterworkspace; irasterdataset PRasterDataset = Prasterws.openrasterdataset (FBS); irasterlayer Prasterlayer = new Rasterlayer () as Irasterlayer; prasterlayer.createfromdataset ( Prasterdataset); return PRasterLayer; &NBSP} event Logic: AxMapControl1.Map.AddLayer (openimage (filePath)); AxMapControl1.ActiveView.Refresh (); Funcolorforraster_classify (Axmapcontrol1.get_layer (0) as Irasterlayer);//only one Rasterlayer AxMapControl1.Activeview.Refresh (); Here is the renderings before and after the rendering:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.