导航

建立shape文件(c#+AE)

Posted on 2009-03-14 20:35  走在路上的行者  阅读(1405)  评论(0)    收藏  举报

           string strFolder = "D:\\zt";
            string strName = "MyShape";
            string strShapeFieldName = "Shape";

            IFeatureWorkspace pFWS;
            IWorkspaceFactory pWorkSpaceF;

            pWorkSpaceF = new ShapefileWorkspaceFactoryClass();
            pFWS = pWorkSpaceF.OpenFromFile(strFolder, 0) as IFeatureWorkspace;

            IFields pFields;
            IFieldsEdit pFieldsEdit;
            pFields = new FieldsClass();

            pFieldsEdit = pFields as IFieldsEdit;

            IField pField;
            IFieldEdit pFieldEdit;
            pField = new FieldClass();
            pFieldEdit = pField as IFieldEdit;

            pFieldEdit.Name_2 = strShapeFieldName;
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;

            IGeometryDef pGeomDef;
            IGeometryDefEdit pGeomDefEdit;
            pGeomDef = new GeometryDefClass();

            pGeomDefEdit = pGeomDef as IGeometryDefEdit;
            pGeomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            pGeomDefEdit.SpatialReference_2 = new UnknownCoordinateSystemClass();


            pFieldEdit.GeometryDef_2 = pGeomDef;

            pFieldsEdit.AddField(pField);


            IFeatureClass pFeatureClass;

            pFeatureClass = pFWS.CreateFeatureClass(strName, pFields, null, null, esriFeatureType.esriFTSimple, strShapeFieldName, "");