日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

AE CreateFeatureClass 创建shp. 删除shp. 向shp中添加要素

發布時間:2023/12/10 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 AE CreateFeatureClass 创建shp. 删除shp. 向shp中添加要素 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/// <summary>/// 創建多邊形shp/// </summary>/// <param name="pPolygon"></param>/// <param name="shpPath"></param>public static void CreatePolygonFeatureClass(IPolygon pPolygon, string shpfolder,string shpname){IWorkspaceFactory pWorkSpaceFac = new ShapefileWorkspaceFactoryClass();IFeatureWorkspace pFeatureWorkSpace = pWorkSpaceFac.OpenFromFile(shpfolder,0) as IFeatureWorkspace;//創建字段集2IFeatureClassDescription fcDescription = new FeatureClassDescriptionClass();IObjectClassDescription ocDescription = (IObjectClassDescription)fcDescription;//創建必要字段IFields fields = ocDescription.RequiredFields;int shapeFieldIndex = fields.FindField(fcDescription.ShapeFieldName); IField field = fields.get_Field(shapeFieldIndex);IGeometryDef geometryDef = field.GeometryDef; IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef; //geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;//geometryDefEdit.SpatialReference_2 = spatialReference;geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;ISpatialReferenceFactory pSpatialRefFac = new SpatialReferenceEnvironmentClass();IProjectedCoordinateSystem pcsSys = pSpatialRefFac.CreateProjectedCoordinateSystem((int)esriSRProjCS4Type.esriSRProjCS_Xian1980_3_Degree_GK_Zone_39);geometryDefEdit.SpatialReference_2 = pcsSys;IFieldChecker fieldChecker = new FieldCheckerClass();IEnumFieldError enumFieldError = null;IFields validatedFields = null; //將傳入字段 轉成 validatedFieldsfieldChecker.ValidateWorkspace = (IWorkspace)pFeatureWorkSpace;fieldChecker.Validate(fields, out enumFieldError, out validatedFields);pFeatureWorkSpace.CreateFeatureClass(shpname, validatedFields, ocDescription.InstanceCLSID, ocDescription.ClassExtensionCLSID, esriFeatureType.esriFTSimple, fcDescription.ShapeFieldName, "");}

?//刪除shp

//如果已存在,那么刪除IFeatureClass pFCChecker = pFeatureWorkSpace.OpenFeatureClass(shpname);if (pFCChecker != null){IDataset pds = pFCChecker as IDataset;pds.Delete();}

//向shp中添加要素

/// <summary>/// 向多邊形shp中添加要素/// </summary>/// <param name="pPolygon">多邊形</param>/// <param name="pFeatureClass">多邊形shp</param>public static void AddFeatureToFeatureClass(IPolygon pPolygon,IFeatureClass pFeatureClass){IFeature pFeature = pFeatureClass.CreateFeature();pFeature.Shape = pPolygon;pFeature.Store(); }

?

//官方例子

public void IFeatureClass_CreateFeature_Example(IFeatureClass featureClass) { //Function is designed to work with polyline data if (featureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline) { return; }//create a geometry for the features shape ESRI.ArcGIS.Geometry.IPolyline polyline = new ESRI.ArcGIS.Geometry.PolylineClass(); ESRI.ArcGIS.Geometry.IPoint point = new ESRI.ArcGIS.Geometry.PointClass(); point.X = 0; point.Y = 0; polyline.FromPoint = point;point = new ESRI.ArcGIS.Geometry.PointClass(); point.X = 10; point.Y = 10; polyline.ToPoint = point;IFeature feature = featureClass.CreateFeature();//Apply the constructed shape to the new features shape feature.Shape = polyline;ISubtypes subtypes = (ISubtypes)featureClass; IRowSubtypes rowSubtypes = (IRowSubtypes)feature; if (subtypes.HasSubtype)// does the feature class have subtypes? { rowSubtypes.SubtypeCode = 1; //in this example 1 represents the Primary Pipeline subtype }// initalize any default values that the feature has rowSubtypes.InitDefaultValues();//Commit the default values in the feature to the database feature.Store();//update the value on a string field that indicates who installed the feature. feature.set_Value(feature.Fields.FindField("InstalledBy"), "K Johnston");//Commit the updated values in the feature to the database feature.Store(); }

轉載于:https://www.cnblogs.com/CSharpLover/p/5787655.html

總結

以上是生活随笔為你收集整理的AE CreateFeatureClass 创建shp. 删除shp. 向shp中添加要素的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。