geoprocessing初步  

geoprocessing初步  2009-04-08 00:12

分类:Arcobjects
字号:    
收到原来学生请求,需要使用geoprocessing来处理数据,这东东,是好用,可是,由于手上没太多数据需要处理,所以练得不多,所以顺便写一下,下次需要时查一下下:
要求是创建新的shp文件,
写了两个版本的,一个python的,一个是c#的,
python代码如下:
import sys,string,os
import win32com.client
gp=win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
try:
    gp.Workspace="D:/gisprogram/pythonTest"
    out_feat_class="test.shp"
    gp.CreateFeatureclass(gp.workspace,out_feat_class,"POLYGON")
except:
    print gp.GetMessages()

c#代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using ESRI.ArcGIS.Geoprocessor;
using ESRI.ArcGIS.DataManagementTools;
using ESRI.ArcGIS.esriSystem ;
namespace CreateFeatureClass
{
    class Program
    {
        static void Main(string[] args)
        {
            Geoprocessor GP = new Geoprocessor();
            GP.SetEnvironmentValue("workspace", @"D:/workdir/program/CreateFeatureClass");
            ESRI.ArcGIS.DataManagementTools.CreateFeatureclass newfeatureclass = new ESRI.ArcGIS.DataManagementTools.CreateFeatureclass() ;
            newfeatureclass.out_name = "test1.shp";
            newfeatureclass.out_path = @"D:/workdir/program/CreateFeatureClass";
            newfeatureclass.geometry_type="POLYGON";
            GP.Execute(newfeatureclass, null);
            
            
            
        }
    }
}
需要提出的是,c#代码中用的类是在9.2下面写的,因为9.2提供了新的geoprocessor类,以及几个有用的直接引用arctoolbox中的类的方法。

来自:http://totofeng.blog.163.com/blog/static/6889108120093801244808/

你可能感兴趣的:(geoprocessing初步  )