创建shapefile

CreateNewShapeFile(string fullName, esriShapeType shapeType, ref IFeatureClass featureClass)
        {
        
            int count = fullName.LastIndexOf(".");
            count = fullName.LastIndexOf("//");
            string folder = fullName.Substring(0, count + 1);
            string name = fullName.Substring(count + 1, fullName.Length - count - 1);


            IWorkspace ipws;
            IWorkspaceFactory ipwsf = new ShapefileWorkspaceFactoryClass();
            ipws = ipwsf.OpenFromFile(folder, 0);
           
            IFeatureWorkspace ifeatws;
            ifeatws = ipws as IFeatureWorkspace;     
            if (featureClass != null)
            {
                System.Windows.Forms.MessageBox.Show("退出");
                throw new System.NotImplementedException();
            }
            //////////////声明必要的对象/////////////////////////////
            IFields pFields = new FieldsClass();
            IField pField = new FieldClass();
            IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
            IFieldEdit pFieldEdit = pField as IFieldEdit;
            IGeometryDef ipGeodef = new GeometryDefClass();
            IGeometryDefEdit ipGeodefEdit = ipGeodef as IGeometryDefEdit;
//          IGeoDataset geoDataset = featureClass as IGeoDataset;
            ISpatialReference ipSpatialRef;
            IUnknownCoordinateSystem iunknowncoord = new UnknownCoordinateSystemClass();
            ipSpatialRef = iunknowncoord;
            ////////////声明结束///////////////////////////////////////
            ipGeodefEdit.GeometryType_2 = (esriGeometryType)shapeType;
            ipSpatialRef.SetMDomain(-10000, 10000);
            ipGeodefEdit.HasM_2 = true;
            ipGeodefEdit.HasZ_2 = true;
            ipGeodefEdit.SpatialReference_2 = ipSpatialRef;
            pFieldEdit.Name_2 = "Shape";
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
            pFieldEdit.GeometryDef_2 = ipGeodef;
            pFieldsEdit.AddField(pField);
            ///////////////////////////////////////////////////////////////////设置shape文件的基本属性
            featureClass=ifeatws.CreateFeatureClass(name, pFields, null, null, esriFeatureType.esriFTSimple, "Shape", "");

            throw new System.NotImplementedException();
        } 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值