Java obtains the size of a shape file.

Source: Internet
Author: User

Initialize the AE Runtime Environment [java] public static void initializski () {EngineInitializer. initializeEngine (); try {AoInitialize aoInit = new AoInitialize (); try {if (aoInit. isProductCodeAvailable (esriLicenseProductCode. esriLicenseProductCodeEngine) = esriLicenseStatus. esriLicenseAvailable) aoInit. initialize (esriLicenseProductCode. esriLicenseProductCodeEngine); else if (aoInit. isProductCodeAvailable (esriLicenseProductCode. esriLicenseProductCodeArcView) = esriLicenseStatus. esriLicenseAvailable) aoInit. initialize (esriLicenseProductCode. esriLicenseProductCodeArcView); else {System. err. println ("check, no ArcGISLicenses. ") ;}} catch (Exception e) {e. printStackTrace () ;}} catch (Exception e) {e. printStackTrace () ;}} get featureclass [java] public static FeatureClass evaluate (String path, String name) throws IOException {FeatureClass featureClass = null; try {ShapefileWorkspaceFactory shapefileWorkspaceFactory = new release (); workspace workspace = new Workspace (shapefileWorkspaceFactory. openFromFile (path, 0); featureClass = new FeatureClass (workspace. openFeatureClass (name);} catch (IOException e) {throw e;} return featureClass ;} calculate the area in the shape file [java]/*** to obtain the area of the shape file surface type * @ param featureClass * @ param type * @ return */public Double getShapeArea (FeatureClass featureClass, string type) {Double allArea = 0d; try {IQueryFilter pQueryFilter = new QueryFilter (); int featureCount = featureClass. featureCount (pQueryFilter); if (type. equals ("polygon") {for (int I = 0; I <featureCount; I ++) {IGeometry ig = featureClass. getFeature (I ). getShape (); Polygon polygon = (Polygon) ig; polygon. getArea () ;}} catch (AutomationException e) {e. printStackTrace ();} catch (IOException e) {e. printStackTrace ();} finally {com. esri. arcgis. system. engineInitializer. release (featureClass);} return allArea ;}

Related Article

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.