博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ArcEngine创建ShapeFile文件
阅读量:6313 次
发布时间:2019-06-22

本文共 2208 字,大约阅读时间需要 7 分钟。

public static void CreateShapeFile(string strShapeFolder, string strShapeName, string wkt)

{

//打开工作空间

const string strShapeFieldName = "shape";

IWorkspaceFactory pWSF = new ShapefileWorkspaceFactoryClass();

IFeatureWorkspace pWS = (IFeatureWorkspace)pWSF.OpenFromFile(strShapeFolder, 0);

//设置字段集

IFields pFields = new FieldsClass();
IFieldsEdit pFieldsEdit = (IFieldsEdit)pFields;

//设置字段

IField pField = new FieldClass();
IFieldEdit pFieldEdit = (IFieldEdit)pField;

//创建类型为几何类型的字段
pFieldEdit.Name_2 = strShapeFieldName;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;

//为esriFieldTypeGeometry类型的字段创建几何定义,包括类型和空间参照

IGeometryDef pGeoDef = new GeometryDefClass(); //The geometry definition for the field if IsGeometry is TRUE.
IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit)pGeoDef;
pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
pGeoDefEdit.SpatialReference_2 = new UnknownCoordinateSystemClass();

//ISpatialReferenceFactory2 pSpaRefFactory = new SpatialReferenceEnvironmentClass();

//pSpaRefFactory.CreateESRISpatialReferenceFromPRJFile(@"E:\temp\Suzhou_1954_3_Degree_GK_CM_120E.prj");

pFieldEdit.GeometryDef_2 = pGeoDef;

pFieldsEdit.AddField(pField);

//添加其他的字段

pField = new FieldClass();
pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Name_2 = "wkt";
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
pFieldsEdit.AddField(pField);

IField pField2 = new FieldClass();

IFieldEdit pFieldEdit2 = (IFieldEdit)pField2;
pFieldEdit2.Type_2 = esriFieldType.esriFieldTypeOID;
pFieldsEdit.AddField(pField2);

IField pField3 = new FieldClass();

IFieldEdit pFieldEdit3 = (IFieldEdit)pField3;
pFieldEdit3.Name_2 = "str1";
pFieldEdit3.Type_2 = esriFieldType.esriFieldTypeString;
pFieldsEdit.AddField(pField3);

IField pField4 = new FieldClass();

IFieldEdit pFieldEdit4 = (IFieldEdit)pField4;
pFieldEdit4.Name_2 = "str2";
pFieldEdit4.Type_2 = esriFieldType.esriFieldTypeString;
pFieldsEdit.AddField(pField4);

//创建shapefile

pWS.CreateFeatureClass(strShapeName, pFields, null, null, esriFeatureType.esriFTSimple, strShapeFieldName, "");

//IFeatureClass pointFC = Common.CreateFeatureClass(pointfeatureClassName, pointtype, sr, pFWS, fieldList);

}

转载于:https://www.cnblogs.com/khfang/p/7685302.html

你可能感兴趣的文章
Linux 关于Transparent Hugepages的介绍
查看>>
full decommisson of GDC
查看>>
go 与mysql
查看>>
阿里云正式推出航空大脑,帮助机场提高航班周转效率
查看>>
VMware Workstation :The VMware Authorization Service is not running.
查看>>
MySQL进程常见的State【转】
查看>>
不再局限于人脸识别,北大团队开发出“车脸”识别技术
查看>>
Java线程池
查看>>
Java防盗链在报表中的应用实例
查看>>
7.2bash 脚本选项及组合条件测试
查看>>
MySQL MyISAM/InnoDB高并发优化经验
查看>>
rsync使用
查看>>
varnish
查看>>
vim 使用简单教程
查看>>
SUSE linux 系统管理之时钟同步
查看>>
CREELINKS平台_处理器CeAd资源使用说明(CeAd的配置与使用)
查看>>
Linux协议栈(5)——net-device及代码
查看>>
镁客网每周硬科技领域投融资汇总(12.24-12.30),未来医疗占比猛增,阿里两项亿级投资...
查看>>
Windows中杀死占用某个端口的进程
查看>>
美妆算法---人脸审美标准
查看>>