欢迎使用CSDN-markdown编辑器
来源:互联网 发布:海马模拟器 for mac 编辑:程序博客网 时间:2024/06/02 05:23
根据博客园-迈腾加多宝的文章进行的改进http://www.cnblogs.com/changxy/p/4223948.html。
对大数据量的点生成Shap图层代码如下:
C#代码如下,希望对大家有帮助,有什么问题可以留言讨论
private void CreateShpFromPointList(List<CPoint> cPointList, string OutputFileName) { if (cPointList.Count == 0) { MessageBox.Show("输出的数据为空,请检查数据重试!"); return; } string GpsFileName; string GpsFileFolder; IFeatureClass pFeatureClass; GpsFileName = System.IO.Path.GetFileName(OutputFileName); GpsFileFolder = System.IO.Path.GetDirectoryName(OutputFileName); //创建工作空间 IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory(); IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(GpsFileFolder, 0); //创建地理参考坐标WGS1984 ISpatialReferenceFactory pSpatialReferenceFactory = new SpatialReferenceEnvironmentClass(); IGeographicCoordinateSystem pGCS = new GeographicCoordinateSystemClass(); pGCS = pSpatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); ISpatialReference pSpatialReference = pGCS; if (File.Exists(OutputFileName)) { pFeatureClass = pFeatureWorkspace.OpenFeatureClass(GpsFileName); IDataset pDataset = pFeatureClass as IDataset; 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.esriFieldTypeGeometry; IGeometryDefEdit pGeoDef = new GeometryDefClass(); IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit)pGeoDef; pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint; pGeoDefEdit.SpatialReference_2 = pSpatialReference; pFieldEdit.GeometryDef_2 = pGeoDef; pFieldsEdit.AddField(pField); pField = new FieldClass(); pFieldEdit = (IFieldEdit)pField; pFieldEdit.Name_2 = "序号"; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; pFieldsEdit.AddField(pField); pField = new FieldClass(); pFieldEdit = (IFieldEdit)pField; pFieldEdit.Name_2 = "X"; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble; pFieldsEdit.AddField(pField); pField = new FieldClass(); pFieldEdit = (IFieldEdit)pField; pFieldEdit.Name_2 = "Y"; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble; pFieldsEdit.AddField(pField); pField = new FieldClass(); pFieldEdit = (IFieldEdit)pField; pFieldEdit.Name_2 = "Z"; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble; pFieldsEdit.AddField(pField); pFeatureClass = pFeatureWorkspace.CreateFeatureClass(GpsFileName, pFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", ""); string name; double dx; double dy; double dz; IPoint point; IFeatureBuffer pFeatureBuffer = pFeatureClass.CreateFeatureBuffer(); IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true); for (int i = 0; i < cPointList.Count; i++) { point = new PointClass(); name = cPointList[i].Name; dx = cPointList[i].X; dy = cPointList[i].Y; dz = cPointList[i].Z; point.X = cPointList[i].X; point.Y = cPointList[i].Y; point.Z = cPointList[i].Z; pFeatureBuffer.Shape = point; pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("序号"), name); pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("X"), dx); pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("Y"), dy); pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("Z"), dz); pFeatureCursor.InsertFeature(pFeatureBuffer); } }
0 0
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- openstack glance-api-paster
- TreeMap Comparator 排序
- [FAQ12402]OTG/SD卡热拔插引起的Gallery NE问题
- OC-Js的交互问题
- Quartz任务调度快速入门
- 欢迎使用CSDN-markdown编辑器
- 学习javaSE基础中遇到的一些难点的总结
- android添加常驻图标到状态栏
- iOS开发面试题:#import 跟#include @class区别
- Linux - How to check processor and cpu details
- 仿qq通话界面可拖拽那个头像
- Centos7 Tomcat9 开机启动配置
- Address.js地区下拉JS控件
- ContentProvider源码分析