geoprocessingIt provides features such as data analysis, data management, and data transformation. We use various tools in Arctoolbox to model the framework of our geo-spatial workflow, and perform spatial analysis and processing automatically. Arcengine provides a separate Com.esri.arcgis.geoprocessing.tools toolkit to build the application model through geoprocessing in two development.
Geoprocessor is the primary object that simplifies the task of invoking the Geoprocessing tool. This object is the only access point that executes any geoprocessing tool in ArcGIS and is a coarse-grained object that contains many properties and methods, such as running tools, setting Global environment parameters, checking result messages, performing batches, and accessing data properties. Toolboxes defines a set of tools for geoprocessor that toolboxes can be added to Geoprocessor or removed from. All geoprocessing are stored in toolboxes, Geoprocessor can be implemented by invoking these toolbox to implement the purpose of the geographic tools.
EG:GP Create elements
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 output try {gp = new geoprocess
or ();
Gp.setoverwriteoutput (TRUE);
catch (Exception e) {e.printstacktrace (); }/** * initializes the lowestAvailable 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 a 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 shapefilenam E */public void Createfeatureclass (striNg Shapefilepath, String shapefilename) {try {//Instantiate the Createfeatureclass GP tool Createfeatureclass C
Reatefctool = new Createfeatureclass (Shapefilepath, shapefilename);
Createfctool.setgeometrytype ("point");
Use Utm-zone One north WGS84 spatialreferenceenvironment spatrefenv = new Spatialreferenceenvironment (); Iprojectedcoordinatesystem Projectedcoordsystem = spatrefenv. Createprojectedcoordinatesystem (
esrisrprojcstype.esrisrprojcs_wgs1984utm_11n);
Set the coordinate system on the new feature class Createfctool.setspatialreference (Projectedcoordsystem);
Gp.execute (Createfctool, NULL); Add some fields to the Featureclass addfield Newfield = new AddField (Shapefilepath + file.separator + shapefile
Name, "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 ();
}
}
}