Geoprocessing 它提供了資料分析、資料管理和資料轉換等功能。 利用ArcToolbox中的各種工具為我們的地理空間工作流程進行架構建模,自動執行空間分析與處理。ArcEngine單獨提供com.esri.arcgis.geoprocessing.tools工具包,使得在二次開發中通過Geoprocessing構建應用程式模型。
Geoprocessor 是簡化調用geoprocessing工具任務的主要對象。這個對象是執行ArcGIS中任何geoprocessing工具的唯一訪問點,它是一個粗粒度對象,包含了許多屬性和方法,比如運行工具,設定全域環境參數;檢查結果訊息;執行批處理;訪問資料屬性。Toolboxes為geoprocessor定義了一套工具,Toolboxes可以添加到geoprocessor中,也可以從中刪除。所有的geoprocessing都儲存在Toolboxes中,Geoprocessor可以通過調用這些Toolbox的方式實現執行其中地理工具的目的.
eg:GP建立要素
package com.mapbar.tools;import java.io.File;import com.esri.arcgis.geometry.IProjectedCoordinateSystem;import com.esri.arcgis.geometry.SpatialReferenceEnvironment;import com.esri.arcgis.geometry.esriSRProjCSType;import com.esri.arcgis.geoprocessing.GeoProcessor;import com.esri.arcgis.geoprocessing.tools.datamanagementtools.AddField;import com.esri.arcgis.geoprocessing.tools.datamanagementtools.CreateFeatureclass;import com.esri.arcgis.system.AoInitialize;import com.esri.arcgis.system.EngineInitializer;import com.esri.arcgis.system.esriLicenseExtensionCode;import com.esri.arcgis.system.esriLicenseProductCode;import com.esri.arcgis.system.esriLicenseStatus;public class CreateFeatureClass {private GeoProcessor gp = null;public CreateFeatureClass() {// create the geoprocessor and allow it to overwrite outputtry {gp = new GeoProcessor();gp.setOverwriteOutput(true);} catch (Exception e) {e.printStackTrace();}}/** * Initializes the lowest available ArcGIS License */private static void initializeArcGISLicenses(AoInitialize aoInit) {try {if (aoInit.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine) == esriLicenseStatus.esriLicenseAvailable) {aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);} else if (aoInit.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcView) == esriLicenseStatus.esriLicenseAvailable) {aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeArcView);} else {System.err.println("Could not initialize an Engine or ArcView license. Exiting application.");System.exit(-1);}aoInit.checkOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst);} catch (Exception e) {e.printStackTrace();}}/** * Creates a feature class using specified path and name * * @param shapefilePath * @param shapefileName */public void createFeatureClass(String shapefilePath, String shapefileName) {try {// instantiate the CreateFeatureClass GP toolCreateFeatureclass createFCTool = new CreateFeatureclass(shapefilePath, shapefileName);createFCTool.setGeometryType("point");// use UTM - Zone 11 North WGS84SpatialReferenceEnvironment spatRefEnv = new SpatialReferenceEnvironment();IProjectedCoordinateSystem projectedCoordSystem = spatRefEnv.createProjectedCoordinateSystem(esriSRProjCSType.esriSRProjCS_WGS1984UTM_11N);// set the coordinate system on the new feature classcreateFCTool.setSpatialReference(projectedCoordSystem);gp.execute(createFCTool, null);// add some fields to the featureclassAddField newField = new AddField(shapefilePath + File.separator+ shapefileName, "textField", "text");newField.setFieldLength(40);gp.execute(newField, null);newField.setFieldName("longField");newField.setFieldType("long");gp.execute(newField, null);newField.setFieldName("doubField");newField.setFieldType("double");newField.setFieldScale(2);newField.setFieldPrecision(20);gp.execute(newField, null);} catch (Exception e) {e.printStackTrace();}}public static void main(String[] args) {try {// Initialize the engine and licenses.EngineInitializer.initializeEngine();AoInitialize aoInit = new AoInitialize();initializeArcGISLicenses(aoInit);String outPath = "E:\\arcgis\\point";String outName = "POI.shp";CreateFeatureClass cf = new CreateFeatureClass();cf.createFeatureClass(outPath, outName);aoInit.shutdown();} catch (Exception e) {e.printStackTrace();}}}