• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

c#调用ArcEngine的GP工具

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

           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 首先是把ASCII文件转换为Raster文件

                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)

                {

                    // 然后把转好的Raster文件重新分类

                    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)

                    {

                        // 把分类好的Raster文件转换为矢量文件

                        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");


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#删除只读文件或文件夹(解决File.Delete无法删除文件)发布时间:2022-07-10
下一篇:
C#获取父控件容器的属性发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap