



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
using System;using System.Collections.Generic;using System.Linq;using System.Text;using ESRI.ArcGIS.esriSystem;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.SystemUI;using ESRI.ArcGIS.Geometry;using ESRI.ArcGIS.Geodatabase;using ESRI.ArcGIS.DataSourcesFile;using ESRI.ArcGIS.DataSourcesOleDB;namespace Moso_Bamboo_Forest_Visualization class LoadExcel private IFeatureClass createfeatureclass() string tempStorePath = System.Environment.CurrentDirectory; IWorkspaceFactory workspacefactory = new ShapefileWorkspaceFactoryClass(); IFeatureWorkspace featureworkspace = (IFeatureWorkspace)workspacefactory.OpenFromFile(tempStorePath, 0); string layerName = points; IFields pFields = new FieldsClass(); IFieldsEdit pFieldsEdit = pFields as IFieldsEdit; / IField shapeField = new FieldClass(); IFieldEdit shapeEdit = shapeField as IFieldEdit; shapeEdit.Name_2 = Shape; shapeEdit.Type_2 = esriFieldType.esriFieldTypeGeometry; IGeometryDef pGeometryDef = new GeometryDefClass(); IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit; pGeometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint; ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass(); ISpatialReference sr1; IProjectedCoordinateSystem pcs = srFactory.CreateProjectedCoordinateSystem(102100); sr1 = pcs; pGeometryDefEdit.SpatialReference_2 = sr1; shapeEdit.GeometryDef_2 = pGeometryDefEdit; pFieldsEdit.AddField(shapeField); IField x = new FieldClass(); IFieldEdit xx = x as IFieldEdit; xx.Name_2 = X; xx.Type_2 = esriFieldType.esriFieldTypeDouble; pFieldsEdit.AddField(x); IField y = new FieldClass(); IFieldEdit yy = y as IFieldEdit; yy.Name_2 = Y; yy.Type_2 = esriFieldType.esriFieldTypeDouble; pFieldsEdit.AddField(y); esriFeatureType pfeaturetype = esriFeatureType.esriFTSimple; IFeatureClass tempFeatureClass; tempFeatureClass = featureworkspace.CreateFeatureClass(layerName, pFields, null, null, pfeaturetype, Shape, text); return tempFeatureClass; public ILayer myGetExcelTable(string path) ESRI.ArcGIS.esriSystem.IPropertySet proset = new ESRI.ArcGIS.esriSystem.PropertySetClass(); string strcon = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + path + ;Extended Properties=Excel 8.0; proset.SetProperty(CONNECTSTRING, strcon); IWorkspaceFactory workspf = new ESRI.ArcGIS.DataSourcesOleDB.OLEDBWorkspaceFactoryClass(); IFeatureWorkspace fworkfac = workspf.Open(proset, 0) as IFeatureWorkspace; IQueryDef myQueryDef = fworkfac.CreateQueryDef(); myQueryDef.Tables = Sheet1$; myQueryDef.SubFields = *; myQueryDef.WhereClause = ; ICursor myCursor = myQueryDef.Evaluate(); IRow myRow; IPoint point = new PointClass(); ILayer newlayer; IFeatureClass newfeatureclass = createfeatureclass(); ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass(); ISpatialReference sr1; IProjectedCoordinateSystem pcs = srFactory.CreateProjectedCoordinateSystem(102100); sr1 = pcs; while (myRow = myCursor.NextRow() != null) point.PutCoords(double.Parse(myRow.get_Value(0).ToString(), double.Parse(myRow.get_Value(1).ToString(); point.SpatialReference = sr1; IFeatureCursor m_cursor = newfeatureclass.Insert(true); IFeatureBuffer m_buffer = newfeatureclass.CreateFeatureBuffer(); m_buffer.Shape = point; m_buffer.set_Value(newfeatureclass.FindField(X), double.Parse(myRow.get_Value(0).ToString(); m_buffer.set_Value(newfeatureclass.FindField(Y), double.Parse(myRow.get_Value(1).ToString(); m_cursor.InsertFeature(m_buffer
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024-2025学年高中物理 第四章 光 2 全反射说课稿 新人教版选择性必修第一册
- 吉林省通化市外国语学校九年级化学上册 第一单元 课题2 化学是一门以实验为基础的科学说课稿2 (新版)新人教版
- Unit 5 Why do you like pandas 单元整体说课稿 2025-2026学年人教版七年级英语下册
- 中国联通天门市2025秋招笔试行测题库及答案网络优化与维护类
- 3.15 秦汉时期的科技与文化 说课稿 统编版七年级历史上册
- 淮南市中石化2025秋招笔试性格测评专练题库及答案
- 安全知识培训不足分析
- 漳州市中石油2025秋招笔试模拟题含答案法律与合规岗
- 2024年高中语文 第4课 蜀道难说课稿1 新人教版必修3
- 2024-2025春季学期七年级地理下册8.1东南亚(第1课时)说课稿(湘教版)
- 零星工程施工安全培训
- 农业昆虫学-形考测试一-国开(ZJ)-参考资料
- 一年级开学家长会 课件
- 项目驻地(营区)风险评估报告
- 百白破疫苗效力评估的队列研究
- 田径比赛竞赛规则
- +Unit4+I+used+to+be+afraid+of+the+dark+SectionB+1a-1e课件2023-2024学年人教版九年级英语全册
- 2022新高考I卷II卷英语读后续写解读讲评及写作技巧指导课件
- 安徽省物业管理行业专题调研分析报告
- 2023国家电网作业安全风险管控典型生产作业风险定级库
- 媒介经营与管理(课程)课件
评论
0/150
提交评论