/// <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中添加要素的更多相关文章

  1. Unity3D 中的面向对象设计 {游戏对象(创建、删除、获取),以及添加修改组件}

    一.创建游戏对象 游戏对象分三种:(1) 将物体模型等资源由Project工程面板拖拽到Hierarchy层次面板中 (2) 由GameObject菜单创建Unity自带的游戏对象,如Cube.Cam ...

  2. C++、GDAL创建shapefile,并向矢量文件中添加网格

    //总体来说这个过程就是构建数据源->构建层->构建要素->构建形状->关闭数据源. //要包含的GDAL头文件 #include <gdal_priv.h> #i ...

  3. ①创建项目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 ...

  4. linux下软、硬链接的创建和删除

    linux下软.硬链接的创建和删除 在Linux系统中,内核为每一个新创建的文件分配一个Inode(索引结点),每个文件都有一个惟一的inode号.文件属性保存在索引结点里,在访问文件时,索引结点被复 ...

  5. Arcgis engine 指定图层对要素进行创建、删除等操作

    Arcgis engine 指定图层创建点要素 在指定的图层上创建一个点要素,点要素的位置是通过X,Y坐标指定的,下面是具体的注释 .其中 和IFeatureClassWrite接口有关的代码不要好像 ...

  6. SQLServer触发器创建、删除、修改、查看

    一: 触发器是一种特殊的存储过程﹐它不能被显式地调用﹐而是在往表中插入记录﹑更新记录或者删除记录时被自动地激活.所以触发器可以用来实现对表实施复杂的完整性约束. 二: SQL Server为每个触发器 ...

  7. linux命令 - ln - 创建和删除软、硬链接

    linux命令 - ln - 创建和删除软.硬链接 在Linux系统中,内核为每一个新创建的文件分配一个Inode(索引结点),每个文件都有一个惟一的inode号.文件属性保存在索引结点里,在访问文件 ...

  8. 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 ...

  9. 各种隐藏 WebShell、创建、删除畸形目录、特殊文件名、黑帽SEO作弊(转自核大大)

    其实这个问题,经常有朋友问我,我也都帮大家解决了…… 但是现在这些现象越来越严重,而且手法毒辣.隐蔽.变态,清除了又来了,删掉了又恢复了,最后直接找不到文件了,但是访问网站还在,急的各大管理员.站长抓 ...

随机推荐

  1. ros的源码阅读

    测试代码,使用xmlrpc与roscore通信 ros的框架是使用rpc与server端通信,server维护topic的publisher,subscriber,param server,servi ...

  2. 测试使用Windows Live Writer

    目前是在win7系统下面使用的,曾经在winxp下去配置,却失败了,难道不支持xp? Windows Live Writer好像不支持代码关键字高亮显示啊. int main(void) { prin ...

  3. c#中的类型转换

    Parse类型转换 Parse()函数 int.double都能调用Parse()函数,Parse(string str);如果转换成功就成功,失败就会抛出一个异常; TryParse()函数 相应地 ...

  4. 【笔记】W3C CSS关键属性

    white-space属性: white-space 属性设置如何处理元素内的空白. 可能的值 值 描述 normal 默认值,合并所有空格,换行符会被浏览器忽略 pre 空白会被浏览器保留.其行为方 ...

  5. ActiveMQ.xml文件的主要配置

    ActiveMQ.xml文件默认位置位于 activemq/conf/目录下,主要的配置及解析如下:<beans xmlns="http://www.springframework.o ...

  6. OC中的点语法,成员变量的作用域

    点语法 点语法本质是函数的调用,不是像java中那样,是用来访问成员变量的:oc中访问成员变量是用 -> 访问的: Person *p = [Person new]; p.age = 10; / ...

  7. 一个SQL Server 2008 R2 死锁的问题解决

    问题场景:在客户那碰到一个操作卡死的现象 问题解决: 1.如何挂钩是死锁问题:通过代码跟踪,发现是指执行一个SQL语句超时,因此猜想可能是表锁住了 2.如果确认是思索问题:通过SQL发现死锁,以下是相 ...

  8. C#的配置文件App.config使用总结 - 转

    http://blog.csdn.net/celte/article/details/9749389 首先,先说明,我使用的app.config 配置文件的格式如下: <?xml version ...

  9. Codeforces Round #327 (Div. 1) B. Chip 'n Dale Rescue Rangers 二分

    题目链接: 题目 B. Chip 'n Dale Rescue Rangers time limit per test:1 second memory limit per test:256 megab ...

  10. Ext学习-HelloWorld以及基础环境搭建

    1.目的    在eclipse中搭建EXTJS的基础环境,学习如何按照从官方下载的代码中搭建新的Extjs工程 2.主要包含内容:   1.ExtJS文件下载以及目录说明   2.ExtJS开发环境 ...