Using clip as an example, GP calls arctoolbox.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.