AE二次开发中工具箱工具的使用(buffer缓冲区,clip裁剪,union联合,intersect求交等)由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“ae无法创建图像缓冲区”。
AE二次开发中使用ArcMap工具箱中工具的通用方法
在进行AE二次开发中,我们经常会遇到一些空间分析的内容,比如建立buffer(缓冲区),clip(裁剪),union(联合),intersect(求交)……
这些在AE的二次开发中有一个通用的方法: 我们可以将这些工具实例化,然后使用这个工具。
比如在进行SQL查询的时候,我们先建立一个connection对象,然后用command对象调用,得到结果。
同样,在AE二次开发中我们可以用一个Geoproceor对象,调用buffer(或者union,clip,intersect)对象,得到我们想要的结果。
例如在进行求交的分析中,ArcMap中是这样做的:
我们就可以定义一个
ESRI.ArcGIS.AnalysisTools.Intersect inter = new
ESRI.ArcGIS.AnalysisTools.Intersect();//需要添加ESRI.ArcGIS.AnalysisTools引用并using inter.in_features= @“C:BufferLayer.shp;C:xiaofang.shp” inter.out_feature_cla=@“C:23.shp”;inter.join_attributes= “POINT”;inter.output_type = “ALL”;//可以看出设置和ArcMap中完全一致!!//接着开始调用这个Geoproceor工具得出结果 Geoproceorgeoproceor= newGeoproceor();geoproceor.OverwriteOutput = true;//这里是说是否覆盖已经存在的文件 //这里就可以开始执行了
IGeoProceorResult result =(IGeoProceorResult)geoproceor.Execute(inter, null);//在result中相关信息,结果生成的文件已经存在inter.out_feature_cla中了。Result中也有
//下边的是说的对result中信息的使用 if(result.Status!= esriJobStatus.esriJobSucceeded)MeageBox.Show(“求交出错rn”);else
MeageBox.Show(“求交成功!rn”);//还可以像ArcMap一样提示一下是否加载生成的结果图层
下边是一个完整的方法
/// ///对图层的求交操作 ///
///
输入图层 ///
输入图层 ///
输出图层 ///
输出图层的类型 ///
字段的构造方法 publicvoidintesect(string inputLayer1path,string
inputLayer2path,stringoutputLayerPath,stringoutput_type,stringjoin_attributes){ string paths = inputLayer1path + “;” + inputLayer2path;
Geoproceorgeoproceor= newGeoproceor();geoproceor.OverwriteOutput = true;Intersect inter = newESRI.ArcGIS.AnalysisTools.Intersect();inter.in_features = paths;inter.out_feature_cla = outputLayerPath;inter.join_attributes = join_attributes;inter.output_type = output_type;IGeoProceorResult result =(IGeoProceorResult)geoproceor.Execute(inter, null);
if(result.Status!= esriJobStatus.esriJobSucceeded)MeageBox.Show(“求教出错rn”);else
MeageBox.Show(“求交成功rn”);
if(MeageBox.Show(“是否加载求交后的图层?”, “提示!”, MeageBoxButtons.YesNo)== DialogResult.Yes){ IGPUtilitiespGPUtil = newGPUtilitiesCla();IFeatureClapFC;IQueryFilterpQF;pGPUtil.DecodeFeatureLayer(result.GetOutput(0), outpFC, outpQF);int count = pFC.FeatureCount(null);//统计Feature对象个数 IFeatureCursorpCursor = pFC.Insert(true);//提取FeatureCursor对象 IFeatureLayerpFeatureLayer = newFeatureLayerCla();pFeatureLayer.FeatureCla = pFC;axMapControl1.Map.AddLayer(pFeatureLayer);//加载图层对象 } }