ArcGIS Engine two times development-calculates the area of a Shapefile polygon layer feature

Source: Internet
Author: User

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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.