代码由ESRI社区GIScafe提供

AE中新建shapefile,自定义字段           IFields pFields = new FieldsClass();
AE中新建shapefile,自定义字段            IFieldsEdit pFieldsEdit 
= pFields as IFieldsEdit;
AE中新建shapefile,自定义字段            IField pField 
= new FieldClass();
AE中新建shapefile,自定义字段            IFieldEdit pFieldEdit 
= pField as IFieldEdit;
AE中新建shapefile,自定义字段            pFieldEdit.Name_2 
= "shape";
AE中新建shapefile,自定义字段            pFieldEdit.Type_2 
= esriFieldType.esriFieldTypeGeometry;
AE中新建shapefile,自定义字段
AE中新建shapefile,自定义字段            
//set up Geometry Definition
AE中新建shapefile,自定义字段
            IGeometryDef pGeometryDef = new GeometryDefClass();
AE中新建shapefile,自定义字段            IGeometryDefEdit pGeometryDefEdit 
= pGeometryDef as IGeometryDefEdit;
AE中新建shapefile,自定义字段            pGeometryDefEdit.GeometryType_2 
= esriGeometryType.esriGeometryPoint;  //Point,line,polygon et.
AE中新建shapefile,自定义字段
            pGeometryDefEdit.SpatialReference_2 = axMapControl1.SpatialReference;
AE中新建shapefile,自定义字段
AE中新建shapefile,自定义字段            pFieldEdit.GeometryDef_2 
= pGeometryDef;
AE中新建shapefile,自定义字段            pFieldsEdit.AddField(pField);
AE中新建shapefile,自定义字段
AE中新建shapefile,自定义字段            
//新建字段
AE中新建shapefile,自定义字段
            pField = new FieldClass();
AE中新建shapefile,自定义字段            pFieldEdit 
= pField as IFieldEdit;
AE中新建shapefile,自定义字段            pFieldEdit.Length_2 
= 15;
AE中新建shapefile,自定义字段            pFieldEdit.Name_2 
= "SchoolName";
AE中新建shapefile,自定义字段            pFieldEdit.AliasName_2 
= "SchoolName";
AE中新建shapefile,自定义字段            pFieldEdit.Type_2 
= esriFieldType.esriFieldTypeString;
AE中新建shapefile,自定义字段            pFieldsEdit.AddField(pField);
AE中新建shapefile,自定义字段
AE中新建shapefile,自定义字段            
string mappath = @"E:\data";
AE中新建shapefile,自定义字段            
string layername="school";
AE中新建shapefile,自定义字段            IWorkspaceFactory pWorkspaceFactory 
= new ShapefileWorkspaceFactory();
AE中新建shapefile,自定义字段            IFeatureWorkspace pFeatureWorkspace 
= pWorkspaceFactory.OpenFromFile(mappath,0as IFeatureWorkspace;
AE中新建shapefile,自定义字段            pFeatureWorkspace.CreateFeatureClass(layername
+".shp",pFields,null,null,esriFeatureType.esriFTSimple,"shape","");
AE中新建shapefile,自定义字段            axMapControl1.AddShapeFile(mappath,layername
+".shp");

代码中路径名称可以自定义

相关文章: