Arcengine裁剪分析
方法一 :
网上找的方法,在VS2013 ArcEngine10.1 运行时报错,通过客服得知此方法经常错误,大家可以自己测试下。
private void StartClip(IFeatureLayer inputfeaturelayer, IFeatureClass cliplayerClass, IFeatureWorkspace pOutFeatureWorkSapce, string pOutFeatclsName) { Geoprocessor gp = new Geoprocessor(); gp.OverwriteOutput = true; IFeatureClass inputfeatureclass = inputfeaturelayer.FeatureClass; //IFeatureClass clipfeatureclass = cliplayerClass.FeatureClass; IDataset dataset = inputfeatureclass as IDataset; //IWorkspace workspace = dataset.Workspace; //IFeatureWorkspace fworkspace = workspace as IFeatureWorkspace; IFields outfields = inputfeatureclass.Fields; IFeatureClass outfeatureclass = pOutFeatureWorkSapce.CreateFeatureClass(pOutFeatclsName, outfields, null, null, esriFeatureType.esriFTSimple, "Shape", ""); ESRI.ArcGIS.AnalysisTools.Clip clipTool = new ESRI.ArcGIS.AnalysisTools.Clip(inputfeatureclass, cliplayerClass, outfeatureclass); gp.Execute(clipTool, null); IFeatureLayer outlayer = new FeatureLayerClass(); outlayer.FeatureClass = outfeatureclass; outlayer.Name = outfeatureclass.AliasName; //将裁剪输出的加载到当前Mapcontrol上 //pMap.AddLayer((ILayer)outlayer); }
方法二:
调用Clip工具的时候,参数直接写图层路径,经测试此方法可以实现。
private void StartClip(string inputpath, string clippath, string mudipath) { Geoprocessor gp = new Geoprocessor(); gp.OverwriteOutput = true; ESRI.ArcGIS.AnalysisTools.Clip clipTool = new ESRI.ArcGIS.AnalysisTools.Clip(inputpath, clippath, mudipath); gp.Execute(clipTool, null); }
本博有部分内容来自网络,如有问题请联系:hebeilijianghua@qq.com,并注明来自博客园。