GP is very powerful and an important tool for GIS modeling. In arcengine, there are many methods to implement the clip function. You can use the clip method of ibasicgeoprocessor, but GP is undoubtedly the simplest.
public Clip( objectin_cover, objectclip_cover, objectout_cover)输入这三个参数,即可实现clip功能,第一个参数为输入要素,第二个为裁剪要素,最后为保存路径
string SavePath= @"F:\shiyan\最后的战役\ww2.shp";
//保存路径
string file= System.IO.Path.GetDirectoryName(SavePath);
//获取保存目录
string filename=System.IO.Path.GetFileName(SavePath);
//获取保存文件名
string name = System.IO.Path.GetFileNameWithoutExtension(SavePath); //获取不带后缀的文件名
Geoprocessor G = new geoprocessor ();
G. overwriteoutput = true;
// ESRI. arcGIS. analysistools. clip = new clip (@ "F: \ Shiyan \ final battle \ new_shapefile (3 ). SHP ", @" F: \ Shiyan \ final battle \ new_shapefile (4 ). SHP ", @" F: \ Shiyan \ final battle \ ww1.shp ");
ESRI. ArcGIS. analysistools. clip = new clip (featurelayer1, featurelayer2, savepath); // you can use either of the following methods:
Igeoprocessorresult result = (igeoprocessorresult) g. Execute (clip, null );
If (result. Status = esrijobstatus. esrijobsucceeded) // running status
{
MessageBox. Show ("successful! ");
}
// Add the result to the layer.
Iworkspacefactory factory = new shapefileworkspacefactoryclass ();
Iworkspace workspace = factory. openfromfile (file, 0 );
Ifeatureworkspace featureworkspace = workspace as ifeatureworkspace;
Ifeatureclass featureclass = featureworkspace. openfeatureclass (filename );
Ifeaturelayer layer = new featurelayerclass ();
Layer. featureclass = featureclass;
Layer. Name = Name;
Axmapcontrol1.addlayer (layer );
}
Using clip as an example, GP calls arctoolbox.