zoukankan      html  css  js  c++  java
  • geoprocessor test (转载——待测)

    geoprocessing唯一难的地方就是参数,需要根据不同的情况设置,
    我就以intersect方法为例,编程实现两个图层的intersect.
    新建一个项目,添加引用,我们用的工具intersect是在AnalysisTools中的,在form中加一个button,然后实现其方法,如下,
    别忘了添加命名空间

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using ESRI.ArcGIS.ArcMap;
    using ESRI.ArcGIS.Controls;
    using ESRI.ArcGIS.esriSystem;
    using ESRI.ArcGIS.Geoprocessor;
    
    namespace LandEnvaluation
    {
        class gptest
        {
            //实现button click方法
            private void button1_Click(object sender, EventArgs e)
            {
                //构造Geoprocessor
                ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
                //设置参数
                ESRI.ArcGIS.AnalysisTools.Intersect intersect = new ESRI.ArcGIS.AnalysisTools.Intersect();
                intersect.in_features = @"F:/foshan/Data/wuqutu_b.shp;F:/foshan/Data/world30.shp";
                intersect.out_feature_class = @"E:/intersect.shp";
                intersect.join_attributes = "ONLY_FID";
                //执行Intersect工具
                RunTool(gp, intersect, null);
            }
    
            private void RunTool(Geoprocessor geoprocessor, IGPProcess process, ITrackCancel TC)
            {
                // Set the overwrite output option to true
                geoprocessor.OverwriteOutput = true;
    
                try
                {
                    geoprocessor.Execute(process, null);
                    ReturnMessages(geoprocessor);
    
                }
                catch (Exception err)
                {
                    Console.WriteLine(err.Message);
                    ReturnMessages(geoprocessor);
                }
            }
    
            // Function for returning the tool messages.
            private void ReturnMessages(Geoprocessor gp)
            {
                string ms = "";
                if (gp.MessageCount > 0)
                {
                    for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
                    {
                        ms += gp.GetMessage(Count);
                    }
                }
            }
        }
    }
  • 相关阅读:
    mybatis中使用in查询时的注意事项
    单利模式
    jquery编写插件的方法
    python使用sendmail在linux下发送邮件
    python获取命令行输入参数列表
    互联网的实名与匿名
    Python切分字符串
    2017年3月15日留言 ——关于Java卡Applet系列csdn博文
    linux设置定时任务
    经典面试题:用户反映你开发的网站访问很慢可能会是什么原因
  • 原文地址:https://www.cnblogs.com/henyihanwobushi/p/2976596.html
Copyright © 2011-2022 走看看