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; //创建字段集2
IFeatureClassDescription 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; //将传入字段 转成 validatedFields
fieldChecker.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();
}

AE CreateFeatureClass 创建shp. 删除shp. 向shp中添加要素的更多相关文章
- Unity3D 中的面向对象设计 {游戏对象(创建、删除、获取),以及添加修改组件}
一.创建游戏对象 游戏对象分三种:(1) 将物体模型等资源由Project工程面板拖拽到Hierarchy层次面板中 (2) 由GameObject菜单创建Unity自带的游戏对象,如Cube.Cam ...
- C++、GDAL创建shapefile,并向矢量文件中添加网格
//总体来说这个过程就是构建数据源->构建层->构建要素->构建形状->关闭数据源. //要包含的GDAL头文件 #include <gdal_priv.h> #i ...
- ①创建项目testpackage ②在pack2.B中添加方法f ③在类A中添加如下三个成员变量:int型的私有变量i float型的变量f double型的公有变量d 在pack1.B的main方法中为对象a的成员变量f和d分别赋值为2和3 在pack2.C的main方法中为对象a的成员变量d赋值为3
package pack1; public class A { private int i; float f; public double d; public float getF() { retur ...
- linux下软、硬链接的创建和删除
linux下软.硬链接的创建和删除 在Linux系统中,内核为每一个新创建的文件分配一个Inode(索引结点),每个文件都有一个惟一的inode号.文件属性保存在索引结点里,在访问文件时,索引结点被复 ...
- Arcgis engine 指定图层对要素进行创建、删除等操作
Arcgis engine 指定图层创建点要素 在指定的图层上创建一个点要素,点要素的位置是通过X,Y坐标指定的,下面是具体的注释 .其中 和IFeatureClassWrite接口有关的代码不要好像 ...
- SQLServer触发器创建、删除、修改、查看
一: 触发器是一种特殊的存储过程﹐它不能被显式地调用﹐而是在往表中插入记录﹑更新记录或者删除记录时被自动地激活.所以触发器可以用来实现对表实施复杂的完整性约束. 二: SQL Server为每个触发器 ...
- linux命令 - ln - 创建和删除软、硬链接
linux命令 - ln - 创建和删除软.硬链接 在Linux系统中,内核为每一个新创建的文件分配一个Inode(索引结点),每个文件都有一个惟一的inode号.文件属性保存在索引结点里,在访问文件 ...
- Java集合-5. (List)已知有一个Worker 类如下: 完成下面的要求 1) 创建一个List,在List 中增加三个工人,基本信息如下: 姓名 年龄 工资 zhang3 18 3000 li4 25 3500 wang5 22 3200 2) 在li4 之前插入一个工人,信息为:姓名:zhao6,年龄:24,工资3300 3) 删除wang5 的信息 4) 利用for 循
第六题 5. (List)已知有一个Worker 类如下: public class Worker { private int age; private String name; private do ...
- 各种隐藏 WebShell、创建、删除畸形目录、特殊文件名、黑帽SEO作弊(转自核大大)
其实这个问题,经常有朋友问我,我也都帮大家解决了…… 但是现在这些现象越来越严重,而且手法毒辣.隐蔽.变态,清除了又来了,删掉了又恢复了,最后直接找不到文件了,但是访问网站还在,急的各大管理员.站长抓 ...
随机推荐
- Windows下关于Composer使用时出现的问题及解决办法
问题一: Fatal error: Call to undefined method Composer\Package\CompletePackage::getTrans portOptions() ...
- CSS圆角效果
看了院子里一篇关于CSS圆角技巧的文章,试了一下,觉得很好,贴出练习的代码.优秀文章链接: http://www.cnblogs.com/luluping/archive/2010/06/26/176 ...
- 1017. Queueing at Bank (25)
Suppose a bank has K windows open for service. There is a yellow line in front of the windows which ...
- iOS网络编程同步GET方法请求编程
iOS SDK为HTTP请求提供了同步和异步请求两种不同的API,而且可以使用GET或POST等请求方法.我们先了解其中最为简单的同步GET方法请求. 首先实现查询业务,查询业务请求可以在主视图控制器 ...
- 微信/QQ机器人的实现
介绍: Mojo-Webqq和Mojo-Weixin是在github上基于webQQ和网页版WeiXin,用Perl语言实现的开源的客户端框架,它通过插件提供基于HTTP协议的api接口供其他语言或系 ...
- Java程序员使用的20几个大数据工具
最近我问了很多Java开发人员关于最近12个月内他们使用的是什么大数据工具. 这是一个系列,主题为: 语言 web框架 应用服务器 SQL数据访问工具 SQL数据库 大数据 构建工具 云提供商 今天我 ...
- Notes of the scrum meeting(11/1)
meeting time:9:00~10:30p.m.,November 1st,2013 meeting place:20号公寓楼前 attendees: 顾育豪 ...
- Careercup - Facebook面试题 - 6204973461274624
2014-05-02 02:28 题目链接 原题: I/P: N, k O/P: all subset of N with exactly K elements. eg: I/p: N = , K = ...
- 7zip 命令行
转自 http://www.cnblogs.com/langlang/archive/2010/12/01/1893866.html 7z.exe 是 7-Zip 的命令行版本.7z.exe 使用 7 ...
- 2006: [NOI2010]超级钢琴 - BZOJ
Description小Z是一个小有名气的钢琴家,最近C博士送给了小Z一架超级钢琴,小Z希望能够用这架钢琴创作出世界上最美妙的音乐. 这架超级钢琴可以弹奏出n个音符,编号为1至n.第i个音符的美妙度为 ...