收藏 分享(赏)

C#创建shape点.doc

上传人:j35w19 文档编号:7055447 上传时间:2019-05-04 格式:DOC 页数:2 大小:24KB
下载 相关 举报
C#创建shape点.doc_第1页
第1页 / 共2页
C#创建shape点.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

1、C# AE 中创建点状 Shp 文件今天将点写入一个新的 SHP 文件中,自己先做了一个简单试验,一切正常。代码如下private void CreateShpFromPoint()ISpatialReference pSpatialReference = this.axMapData.ActiveView.FocusMap.SpatialReference;string strShapeFolder=“C:/“;string strShapeFile = “test.shp“;string shapeFileFullName = strShapeFolder strShapeFile;IWo

2、rkspaceFactory pWorkspaceFactory= new ShapefileWorkspaceFactory();IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace) pWorkspaceFactory.OpenFromFile(strShapeFolder, 0);IFeatureClass pFeatureClass;if (File.Exists(shapeFileFullName)pFeatureClass = pFeatureWorkspace.OpenFeatureClass(strShapeFile)

3、;IDataset pDataset = (IDataset)pFeatureClass;pDataset.Delete();IFields pFields = new FieldsClass();IFieldsEdit pFieldsEdit = (IFieldsEdit)pFields;IField pField = new FieldClass();IFieldEdit pFieldEdit = (IFieldEdit)pField;pFieldEdit.Name_2 = “SHAPE“;pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeo

4、metry;IGeometryDefEdit pGeoDef = new GeometryDefClass();IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit)pGeoDef;pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;pGeoDefEdit.SpatialReference_2 = pSpatialReference; /new UnknownCoordinateSystemClass();pFieldEdit.GeometryDef_2 = pGeoDef;

5、pFieldsEdit.AddField(pField);pField = new FieldClass();pFieldEdit = (IFieldEdit)pField;pFieldEdit.Name_2 = “ID“;pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;pFieldsEdit.AddField(pField);pField = new FieldClass();pFieldEdit = (IFieldEdit)pField;pFieldEdit.Name_2 = “Pixels“;pFieldEdit.Type_2

6、= esriFieldType.esriFieldTypeInteger;pFieldsEdit.AddField(pField);pFeatureClass = pFeatureWorkspace.CreateFeatureClass(strShapeFile, pFields, null, null, esriFeatureType.esriFTSimple, “SHAPE“, “);IPoint pPoint = new PointClass();pPoint.X = 113.0;pPoint.Y = 23.0;IFeature pFeature = pFeatureClass.Crea

7、teFeature();pFeature.Shape = pPoint;pFeature.set_Value(pFeature.Fields.FindField(“ID“), “D-1“);pFeature.set_Value(pFeature.Fields.FindField(“Pixels“), 1);pFeature.Store();IFeatureLayer pFeaturelayer = new FeatureLayerClass();pFeaturelayer.FeatureClass = pFeatureClass;pFeaturelayer.Name = “layer“;this.axMapData.AddLayer(pFeaturelayer);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报