arcgis 二次开发之工具箱和工具调用

arcgis 二次开发之工具箱和工具调用

///
/// 执行GP工具
///
/// GP对象
/// 使用工具
///
/// 成功返回true/失败返回false
public static bool RunTool(Geoprocessor geoprocessor, IGPProcess process, ITrackCancel
TC)
{
geoprocessor.OverwriteOutput = true;//存在覆盖
try
{
IGeoProcessorResult result =
(IGeoProcessorResult)geoprocessor.Execute(process, null);//取执行结果
if (result != null)
{
if (result.Status == esriJobStatus.esriJobSucceeded) //执行成功
{
return true;
}
} if (geoprocessor.MessageCount > 0) //失败显示错误原因
{
for (int i = 0; i < geoprocessor.MessageCount; i++)
{
MessageBox.Show(geoprocessor.GetMessage(i));
}
return false;
}
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
return false;
}

public static bool Dissolve(string inFeaturesPath, string outFeaturePath, string dissolveFieldName)
        {
            Geoprocessor GP = new Geoprocessor();
            ESRI.ArcGIS.DataManagementTools.Dissolve dissolve = new
            ESRI.ArcGIS.DataManagementTools.Dissolve();
            dissolve.in_features = inFeaturesPath;
            dissolve.out_feature_class = outFeaturePath;
            dissolve.dissolve_field = dissolveFieldName;
            dissolve.multi_part = “false”;
            return RunTool(GP, dissolve, null);
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值