当前位置:文档之家› AE二次开发中工具箱工具的使用(buffer缓冲区,clip裁剪,union联合,intersect求交等)

AE二次开发中工具箱工具的使用(buffer缓冲区,clip裁剪,union联合,intersect求交等)

AE二次开发中使用ArcMap工具箱中工具的通用方法在进行AE二次开发中,我们经常会遇到一些空间分析的内容,
比如建立buffer(缓冲区),clip(裁剪),union(联合),intersect
(求交)……
这些在AE的二次开发中有一个通用的方法:
我们可以将这些工具实例化,然后使用这个工具。

比如在进行SQL查询的时候,我们先建立一个connection对
象,然后用command对象调用,得到结果。

同样,在AE二次开发中我们可以用一个Geoprocessor对象,调
用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_class=@"C:\23.shp" ;
inter.join_attributes= "POINT";
inter.output_type = "ALL";
//可以看出设置和ArcMap中完全一致!!!
//接着开始调用这个Geoprocessor工具得出结果
Geoprocessor geoprocessor= new Geoprocessor();
geoprocessor.OverwriteOutput = true; //这里是说是否覆盖已经存在的文件
//这里就可以开始执行了
IGeoProcessorResult result = (IGeoProcessorResult)geoprocessor.Execute(inter, null); //在result中相关信息,结果生成的文件已经存在inter.out_feature_class中了。

Result中也有
//下边的是说的对result中信息的使用
if (result.Status != esriJobStatus.esriJobSucceeded)
MessageBox.Show("求交出错\r\n");
else
MessageBox.Show("求交成功!\r\n");
//还可以像ArcMap一样提示一下是否加载生成的结果图层
下边是一个完整的方法
///<summary>
///对图层的求交操作
///</summary>
///<param name="inputLayer1path">输入图层</param>
///<param name="inputLayer2path">输入图层</param>
///<param name="outputLayerPath">输出图层</param>
///<param name="output_type">输出图层的类型</param>
///<param name="join_attributes">字段的构造方法</param>
publicvoid intesect(string inputLayer1path,string
inputLayer2path,string outputLayerPath,string output_type,string join_attributes)
{
string paths = inputLayer1path + ";" + inputLayer2path;
Geoprocessor geoprocessor= new Geoprocessor();
geoprocessor.OverwriteOutput = true;
Intersect inter = new ESRI.ArcGIS.AnalysisTools.Intersect();
inter.in_features = paths;
inter.out_feature_class = outputLayerPath;
inter.join_attributes = join_attributes;
inter.output_type = output_type;
IGeoProcessorResult result = (IGeoProcessorResult)geoprocessor.Execute(inter, null);
if (result.Status != esriJobStatus.esriJobSucceeded)
MessageBox.Show("求教出错\r\n");
else
MessageBox.Show("求交成功\r\n");
if (MessageBox.Show("是否加载求交后的图层?", "提示!", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
IGPUtilities pGPUtil = new GPUtilitiesClass();
IFeatureClass pFC;
IQueryFilter pQF;
pGPUtil.DecodeFeatureLayer(result.GetOutput(0), out pFC, out pQF);
int count = pFC.FeatureCount(null); //统计Feature对象个数
IFeatureCursor pCursor = pFC.Insert(true); //提取FeatureCursor对象
IFeatureLayer pFeatureLayer = new FeatureLayerClass(); pFeatureLayer.FeatureClass = pFC;
axMapControl1.Map.AddLayer(pFeatureLayer); //加载图层对象 }
}。

相关主题