ArcGis开发实验报告.doc
《ArcGis开发实验报告.doc》由会员分享,可在线阅读,更多相关《ArcGis开发实验报告.doc(10页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、本科生实验(实习)报告学 院: 资源与环境学院 课程名称: ArcGIS应用与开发 班 级: 09级地理信息系统 姓 名: 张通 学 号: 指导教师: 闫培洁 教务处印制ArcGis开发实验报告1. 实验名称:ArcEngine应用及开发2. 实验目的:熟练并掌握用vs2005开发Gis应用软件。3. 实验要求:根据笔记步骤进行操作,对每一实验内容做好记录;实验后,写出实验报告。认真上机操作,建立感性认识。 实验报告内容包括:实验名称、目的、内容、记录、分析总结。4. 实验步骤及内容: a添加shp文件。b添加lyr文件。c显示洲地图部分属性。d综合以上上三步,做一个综合的显示实验。添加shp
2、文件依次添加ArcGis Engine Toolbarcontrol ArcGis Engine Toccontrol ArcGis Engine Mapcontrol license comtrol这四个控件,调整布局并且关联它们。添加menustrip控件,命名为“添加shp”,并修改属性名称去掉中文。给ArcGis Engine Toolbarcontrol添加“放大”“缩小”“查看属性”三个功能控件。添加openfiledialog1控件。双击menustrip控件,进入代码编写器,编写代码。添加引用:using System.IO;using ESRI.ArcGIS.Geodatab
3、ase;using ESRI.ArcGIS.DataSourcesFile;using ESRI.ArcGIS.Carto;输入代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.IO;using ESRI.ArcGIS.Geodatabase;using ESRI.ArcGIS.DataSourc
4、esFile;using ESRI.ArcGIS.Carto;namespace zt public partial class Form1 : Form public Form1() InitializeComponent(); private void shpToolStripMenuItem_Click(object sender, EventArgs e) IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory(); openFileDialog1.Filter = shapfile文件(*.shp)|*.
5、shp; openFileDialog1.InitialDirectory = D:新建文件夹ArcGISArcGlobeData; openFileDialog1.Multiselect = false; DialogResult pDialogResult = openFileDialog1.ShowDialog(); if (pDialogResult != DialogResult.OK) return; string pPath = openFileDialog1.FileName; string pFolder = Path.GetDirectoryName(pPath); str
6、ing pFileName = Path.GetFileName(pPath); IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(pFolder, 0); IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace; IFeatureClass pFC = pFeatureWorkspace.OpenFeatureClass(pFileName); IFeatureLayer pFlayer = new FeatureLayerClass(); pFla
7、yer.FeatureClass = pFC; pFlayer.Name = pFC.AliasName; ILayer player = pFlayer as ILayer; IMap pMap = axMapControl1.Map; pMap.AddLayer(player); axMapControl1.ActiveView.Refresh(); 添加lyr在原有的基础上添加,新建menustrip控件,命名为“添加lyr”,双击进入代码编写器编写代码。代码如下:openFileDialog1.Filter = lyr文件(*.lyr)|*.lyr; openFileDialog1.I
8、nitialDirectory = D:新建文件夹ArcGISArcGlobeData; openFileDialog1.Multiselect = false; DialogResult pDialogResult = openFileDialog1.ShowDialog(); if (pDialogResult != DialogResult.OK) return; string pFileName = openFileDialog1.FileName; axMapControl1.AddLayerFromFile(pFileName); axMapControl1.ActiveView.
9、Refresh();图层属性在原有的基础上添加,新建menustrip控件,命名为“图层属性”,双击进入代码编写器编写代码。创建windons窗体,命名为FrmAttributeTable.cs从工具箱-数据中往新窗体上添加DataGridView控件把DataGridView的Dock属性设置为Fill在窗体上点击右键,选中“查看代码”为窗体添加“Load”事件处理在FrmAttributeTable.cs源代码顶部添加如下三行代码:using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Geodatabase
10、;在窗体类中添加如下代码 private AxMapControl m_MapCtrl; public FrmAttributeTable(AxMapControl pMapCtrl) InitializeComponent(); m_MapCtrl = pMapCtrl; 为窗体的Load事件处理方法添加代码ILayer pLayer = m_MapCtrl.get_Layer(0); IFeatureLayer pFLayer = pLayer as IFeatureLayer; IFeatureClass pFC = pFLayer.FeatureClass; IFeatureCurso
11、r pFCursor = pFC.Search(null, false); IFeature pFeature = pFCursor.NextFeature(); DataTable pTable = new DataTable(); DataColumn colName = new DataColumn(洲名); colName.DataType = System.Type.GetType(System.String); pTable.Columns.Add(colName); DataColumn colArea = new DataColumn(面积); colArea.DataType
12、 = System.Type.GetType(System.String); pTable.Columns.Add(colArea); int indexOfName = pFC.FindField(CONTINENT); int indexOfArea = pFC.FindField(Area); while (pFeature != null) string name = pFeature.get_Value(indexOfName).ToString(); string area = pFeature.get_Value(indexOfArea).ToString(); DataRow
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ArcGis 开发 实验 报告
限制150内