[AE] 空间分析-Intersect|Clip


求交思路:

以第一图层与第二图层相交为例:

  1. 添加库

    using ESRI.ArcGIS.Geoprocessing;
    using ESRI.ArcGIS.AnalysisTools;
    
  2. 获取图层

    ILayer pLayer1 = axMapControl1.Map.get_Layer(0) as ILayer;
    ILayer pLayer2 = axMapControl1.Map.get_Layer(1) as ILayer;
    
  3. 设置输出路径

    string outPath = @"C:\buffer.shp";
    
  4. 创建表格,用来存将要输入的参数

    IGpValueTableObject pObject = new GpValueTableObjectClass();
    object p1 = pLayer1 as object;
    object p2 = pLayer2 as object;
    pObject.SetColumns(2);
    pObject.AddRow(ref p1);
    pObject.AddRow(ref p2);
    
  5. 创建地理处理

    Geoprocessor pGp = new Geoprocessor();
    pGp.OverwriteOutput = true;
    
  6. 相交工具

    Intersect pIntersect = new Intersect();
    pIntersect.in_features = pObject; //输入参数
    pIntersect.out_feature_class = outpath; //输出路径
    pIntersect.join_attributes = "ALL"; //连接属性
    pGp.Execute(pIntersect, null); //执行
    
  7. 刷新地图,显示

    axMapControl1.ActiveView.Refresh();
    

Clip运算:

ILayer pLayer = axMapControl1.get_Layer(0) as ILayer;
ILayer pLayer_2 = axMapControl1.get_Layer(1) as ILayer;
Geoprocessor pGP = new Geoprocessor();
pGP.OverwriteOutput = true;
ESRI.ArcGIS.AnalysisTools.Clip pClip = new ESRI.ArcGIS.AnalysisTools.Clip();
pClip.clip_features = pLayer; 
pClip.in_features = pLayer_2;
object output = "C:\\OutputServer\\Clip\\ClipResults.shp";
 pClip.out_feature_class = output;
pGP.Execute(pClip, null);
axMapControl1.ActiveView.Refresh();

转载自:https://blog.csdn.net/summer_dew/article/details/79191165

You may also like...

退出移动版