A few days ago, a colleague asked me how to calculate the area of the surface layer, I am also a long time did not do AE thing, a simple check, tell him to use Iarea interface. In the afternoon, he still did not solve the problem, continue to resort to me. I Baidu, did not find the corresponding article, so I realized that this simple thing, may be a lot of contact AE not deep people, really is very rare things. The hardest part is probably not knowing how to do it, just like my colleague. I soon told him to use the Iarea interface, but he was surprised to ask me "How do you know?" , and said he also found that "seems to use this interface", of course, this is the first level, belongs to the beginning, has just begun to contact AE, all things basically rely on the search engine to solve, from the Internet to find the code to solve the problem, can not find the solution. Another level of the player is to know to use an interface, but do not know how to use, this level, even if the introduction, but not proficient, encountered problems do not know how to start. In fact, no matter what level, all should learn to see the class diagram of AE and help, especially the class diagram, in the installation directory of the diagram directory, see more natural will be handy. Needless to say, the following is a trial code I wrote, published, hoping to help those with the needs of children's shoes, to save them some time.
Using System.runtime;using system.runtime.interopservices;using ESRI. Arcgis.geodatabase;using ESRI. Arcgis.datasourcesfile;using ESRI. Arcgis.geometry; private void Form1_Click (object sender, EventArgs e) {iworkspacefactory pwsf = null; Double Darea = 0; try {pwsf = new Shapefileworkspacefactoryclass (); Ifeatureworkspace PWS = Pwsf.openfromfile (@ "h:\ water flooded area", 0) as Ifeatureworkspace; Ifeatureclass PFC = Pws.openfeatureclass ("Water flooded area topic. shp"); Ifeaturecursor pfeaturecur = Pfc.search (null, FALSE); IFeature pfeature = Pfeaturecur.nextfeature (); while (pfeature! = null) {if (PFeature.Shape.GeometryType = = Esrigeometrytype.esrigeome Trypolygon) {Iarea Parea = Pfeature.shape as Iarea; Darea = Darea + Parea.area; } Pfeature = Pfeaturecur.nextfeature (); } marshal.releasecomobject (Pfeaturecur); } catch (System.Exception ex) {} marshal.releasecomobject (PWS F); }
ArcGIS Engine two times development-calculates the area of a Shapefile polygon layer feature