cgl 坚持、努力终有所获

  博客园 :: 首页 :: 联系 :: 订阅 订阅 :: 管理
  16 Posts :: 1 Stories :: 3 Comments :: 0 Trackbacks

公告

           IAoInitialize m_AoInitialize = new AoInitializeClass();

 

            esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;

 

            licenseStatus = m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo);

            if (licenseStatus == esriLicenseStatus.esriLicenseCheckedOut)

            {

                Geoprocessor tGp = new Geoprocessor();

                tGp.OverwriteOutput = true;

 

 

 

                licenseStatus = m_AoInitialize.IsExtensionCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine,esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst);

                licenseStatus = m_AoInitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst);

                

                //LICenced arcengine

                ESRI.ArcGIS.ConversionTools.ASCIIToRaster tASC = new ESRI.ArcGIS.ConversionTools.ASCIIToRaster();

                tASC.data_type = "FLOAT";

                tASC.in_ascii_file = pWorkSpacePath + @"a1.txt";

                tASC.out_raster = pWorkSpacePath + "a1.img";

                //ScrollToBottom("ASCIIToRaster");

                IGeoProcessorResult tGeoResult = (IGeoProcessorResult)tGp.Execute(tASC, null);

                if (tGeoResult.Status == ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded)

                {

 

                    ESRI.ArcGIS.SpatialAnalystTools.Reclassify tReclass = new ESRI.ArcGIS.SpatialAnalystTools.Reclassify();

                    tReclass.in_raster = pWorkSpacePath + "a1.img";

                    tReclass.missing_values = "NODATA";

                    tReclass.out_raster = pWorkSpacePath + @"Out3.img";

                    tReclass.reclass_field = "VALUE";

                    tReclass.remap = "0 958 10;958 988 20;988 990 30;990 1000 40;1000 1100 50";

                   // ScrollToBottom("Reclassify");

                    tGeoResult = (IGeoProcessorResult)tGp.Execute(tReclass, null);

                    if (tGeoResult.Status == ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded)

                    {

                        ESRI.ArcGIS.ConversionTools.RasterToPolygon tRTP = new ESRI.ArcGIS.ConversionTools.RasterToPolygon();

                        tRTP.in_raster = pWorkSpacePath + "Out3.img";

                        tRTP.out_polygon_features = pWorkSpacePath + "a2_shp.shp";

                        tRTP.raster_field = "VALUE";

                        tRTP.simplify = "SIMPLIFY";

                        //ScrollToBottom("RasterToPolygon");

                        tGeoResult = (IGeoProcessorResult)tGp.Execute(tRTP, null);

                        if (tGeoResult.Status == ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded)

                        {

                            licenseStatus = m_AoInitialize.CheckInExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst);

                            {

                                ESRI.ArcGIS.DataManagementTools.SmoothPolygon tSP = new ESRI.ArcGIS.DataManagementTools.SmoothPolygon();

                                tSP.algorithm = "PAEK";

                                tSP.in_features = pWorkSpacePath + "a2_shp.shp";

                                tSP.out_feature_class = pWorkSpacePath + "a2_shp_smooth.shp";

                                tSP.tolerance = "2";

                                tSP.endpoint_option = "FIXED_ENDPOINT";

                                tSP.error_option = "FLAG_ERRORS";

                                ScrollToBottom("SmoothPolygon");

                                tGeoResult = (IGeoProcessorResult)tGp.Execute(tSP, null);

                            }

                        }

                    }

                }

                // arcengine liencesd 当使用高版本的liencesd在使用中,如果需要低版本的liencesd,需要动态签出liencesd,不然将不会执行成功!

               // writeMessage(tGp);

            }

           

            MessageBox.Show("ok");

posted on 2012-02-09 22:39 cgl 坚持、努力终有所获 阅读(285) 评论(0) 编辑 收藏