c# 调用ArcEngine的GP工具

时间:2021-11-10 05:36:27

IAoInitialize m_AoInitialize = new AoInitializeClass(); esriLicenseStatuslicenseStatus = esriLicenseStatus.esriLicenseUnavailable; licenseStatus = m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo); if (licenseStatus == esriLicenseStatus.esriLicenseCheckedOut) { GeoprocessortGp = newGeoprocessor(); tGp.OverwriteOutput = true; licenseStatus = m_AoInitialize.IsExtensionCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine,esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst); licenseStatus = m_AoInitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst); //LICenced arcengine ESRI.ArcGIS.ConversionTools.ASCIIToRastertASC = newESRI.ArcGIS.ConversionTools.ASCIIToRaster(); tASC.data_type = "FLOAT"; tASC.in_ascii_file = pWorkSpacePath + @"a1.txt"; tASC.out_raster = pWorkSpacePath + "a1.img"; //ScrollToBottom("ASCIIToRaster"); IGeoProcessorResulttGeoResult = (IGeoProcessorResult)tGp.Execute(tASC, null); if (tGeoResult.Status == ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded) { ESRI.ArcGIS.SpatialAnalystTools.ReclassifytReclass = newESRI.ArcGIS.SpatialAnalystTools.Reclassify(); tReclass.in_raster = pWorkSpacePath + "a1.img"; tReclass.missing_values = "NODATA"; tReclass.out_raster = pWorkSpacePath + @"Out3.img"; tReclass.reclass_field = "VALUE"; tReclass.remap = "0 958 10;958 988 20;988 990 30;990 1000 40;1000 1100 50"; // ScrollToBottom("Reclassify"); tGeoResult = (IGeoProcessorResult)tGp.Execute(tReclass, null); if (tGeoResult.Status == ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded) { ESRI.ArcGIS.ConversionTools.RasterToPolygontRTP = newESRI.ArcGIS.ConversionTools.RasterToPolygon(); tRTP.in_raster = pWorkSpacePath + "Out3.img"; tRTP.out_polygon_features = pWorkSpacePath + "a2_shp.shp"; tRTP.raster_field = "VALUE"; tRTP.simplify = "SIMPLIFY"; //ScrollToBottom("RasterToPolygon"); tGeoResult = (IGeoProcessorResult)tGp.Execute(tRTP, null); if (tGeoResult.Status == ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded) { licenseStatus = m_AoInitialize.CheckInExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst); { ESRI.ArcGIS.DataManagementTools.SmoothPolygontSP = newESRI.ArcGIS.DataManagementTools.SmoothPolygon(); tSP.algorithm = "PAEK"; tSP.in_features = pWorkSpacePath + "a2_shp.shp"; tSP.out_feature_class = pWorkSpacePath + "a2_shp_smooth.shp"; tSP.tolerance = "2"; tSP.endpoint_option = "FIXED_ENDPOINT"; tSP.error_option = "FLAG_ERRORS"; ScrollToBottom("SmoothPolygon"); tGeoResult = (IGeoProcessorResult)tGp.Execute(tSP, null); } } } } // arcengine liencesd 当使用高版本的liencesd在使用中,如果需要低版本的liencesd,需要动态签出liencesd,不然将不会执行成功! // writeMessage(tGp); } MessageBox.Show("ok");

giszhouGeoprocessing调用ArcToolBox工具使用总结

Geoprocessing是ArcGIS提供的一个非常实用的工具,借由Geoprocessing工具可以方便的调用ArcToolBox中提供的各类工具,本文在ArcEngine9.2平台环境下总结了调用ArcToolBox工具的使用方法:

1、调用ArcToolBox工具方法

以ArcToolBox->Analysis Tools->Proximity->Buffer工具的调用为例,C#代码如下:

using ESRI.ArcGIS.AnalysisTools;         //添加引用
         using ESRI.ArcGIS.Geoprocessor;