GIS实验报告课件

合集下载

GIS原理实验一实验报告

GIS原理实验一实验报告

GIS原理实验一实验报告
实验一:GIS原理实验报告
一、实验目的:
1.了解GIS原理的基本概念和基本原理;
2.掌握ArcGIS软件的基本操作方法;
二、实验仪器与材料:
1.计算机;
2.ArcGIS软件。

三、实验原理及方法:
1.实验原理:
GIS(地理信息系统)是一种用来存储、管理、查询、分析和显示地理位置相关的数据的系统。

它通过将地理数据与属性数据结合起来,可以用来理解和分析地理问题。

GIS技术在地理学、城市规划、环境科学等领域具有广泛的应用。

2.实验方法:
四、实验步骤:
1.启动ArcGIS软件,在主界面点击“打开”按钮,选择一个已有的地理数据文件进行加载。

3.通过“绘制”工具栏的不同绘图工具,可以在地图上绘制点、线、面等地理要素。

4.选择“选择”工具栏,可以对地理要素进行选择操作,如选择一个
区域内的所有要素。

5.选择“查询”工具栏,可以对地理要素进行属性查询操作,如查询
其中一字段大于其中一值的要素。

6.选择“分析”工具栏,可以对地理要素进行空间分析操作,如计算
两个要素之间的距离。

五、实验结果与分析:
六、实验总结:
七、实验心得:
通过本次实验,我对GIS原理有了更深入的了解,并掌握了ArcGIS
软件的基本操作方法。

在实验过程中,我遇到了一些困难,但通过查阅相
关资料和询问老师的帮助,我顺利完成了实验。

实验中,我发现GIS技术
的应用非常广泛,对于我们理解地理问题和进行地理数据分析非常有帮助。

我会继续学习和研究GIS技术,提高自己的技能水平。

GIS课程实验报告

GIS课程实验报告

GIS课程实验报告姓名:学号:学院:班级:目录1.地理配准与空间建库 (2)1.1实验要求 (2)1.2实验思路 (3)1.3实验步骤 (3)1.4实验总结 (9)2.邻近分析 (10)2.1实验要求 (10)2.2实验思路 (10)2.3实验步骤 (11)2.4实验总结 (21)3.空间分析练习:叠置分析 (22)3.1实验要求 (22)3.2实验思路 (22)3.3实验步骤 (22)3.4实验总结 (31)4.ArcMap制图-地图版面设计 (33)5.1实验要求 (33)5.2实验思路 (33)5.3实验步骤 (33)5.4实验总结 (51)1.地理配准与空间建库1.1实验要求1、利用影像配准(Georeferencing)工具进行影像数据的地理配准2、编辑器的使用(点要素、线要素、多边形要素的数字化)。

3、利用ArcCatalog管理地理空间数据库,理解Personal Geodatabse空间数据库模型的有关概念。

4、掌握在ArcMap中编辑属性数据的基本操作。

5、掌握根据GPS数据文件生成矢量图层的方法和过程。

1.2实验思路本次实验是将扫描的地形图栅格文件,通过选择控制点,将屏幕坐标转换到地理坐标中,设定数据框的属性,规划单位及坐标系统。

然后对纠正后的地图进行重采样处理。

利用ArcGis 的交互性处理,在Catalog中创建数据库,添加要素类型,之后在ArcMap界面中编辑,进行分层矢量化处理,将地形地物分类存入数据库中。

1.3实验步骤1.3.1加载数据和影像配准工具打开ArcMap,添加“地理配准”工具栏,单击右键弹出工具栏,选择“地理配准”。

把需要进行配准的影像—70011-1.TIF增加到ArcMap中1.3.2输入控制点点击“地理配准”工具栏中“添加控制点”选项,在图中选择控制点。

输入其实际坐标。

2)用相同的方法,在影像上增加多个控制点(大于7个),输入它们的实际坐标。

点击“影像配准”工具栏上的“查看链接表”按钮。

《GIS原理与应用》课程实验报告4

《GIS原理与应用》课程实验报告4

《GIS原理与应用》课程实验报告四实验名称空间数据处理实验目的1.掌握空间数据处理(融合、拼接、剪切、交叉、合并)的基本方法,原理。

领会其用途。

2.掌握地图投影变换的基本原理与方法。

3.熟悉ArcGIS中投影的应用及投影变换的方法、技术4.了解地图投影及其变换在实际中的应用。

实验原理空间数据处理是基于已有数据派生新数据的一种方法。

是通过空间分析方法来实现的。

是基于矢量数据进行的,包括如下几种常用的操作:融合,剪切,拼接,合并(并集),相交(交集)。

实验数据云南县界.shp; Clip.shp西双版纳森林覆盖.shp 西双版纳县界.shp实验过程记录:一、试验主要步骤第1步裁剪要素在ArcMap中,添数据GISDATA\云南县界.shp,添加数据GISDATA\Clip.shp (Clip 中有四个要素)激活Clip图层。

选中Clip图层中的一个要素,点击打开ArcToolbox,指定输出要素类路径及名称,这里请命名为“云南县界_Clip1”指定输入类:云南县界指定剪切要素:Clip(必须是多边形要素),重复以上的操作步骤,完成操作后将得到共四个图层。

注意确保不要选中“云南县界”中的要素,如果选择了“云南县界”中的要素裁剪完成的只是被选中的那一部分要素。

第2步 拼接图层在ArcMap 中新建地图文档,加载你在剪切要素操作中得到的四个图层 点击打开ArcToolbox ,在ArcToolbox 中执行“追加”命令,输出要素:设定为 云南县界_Clip1,输入要素:依次添加其它三个图层,右键点击图层“云南县界_Clip1”,在出现的右键菜单中执行“数据”->”导出数据”。

指定导入数据的路径和名称:YNOK.shp,通过以上操作我们就完成了将4个图层拼接为一个图层的处理。

四个图层一个图层加载数据YNOK.shp ,查看图层及打开其属性表看看与“云南县界”中的属性表有何区别。

(右下图可知YNOK 的记录比云南县界的记录要多,各属性值也不完全一样。

GIS原理实验二实验报告

GIS原理实验二实验报告

GIS原理实验二实验报告1、阐述基本原理和概念(要素类、要素数据集)答:要素类(feature class):在ArcGIS中是指具有相同的几何特征的要素集合,比如点的集合,表现为shapefile或者是Geodatabase中的feature class。

要素数据集(feature dataset):在ArcGIS中表现为geodatabase中的feature dataset,在一个数据集中所有的feature class都具有相同的坐标系统,一般也是在相同的区域。

Geodatabse 空间数据库模型的特点。

答:空间参考Geodatabase 在要素类和数据集中对空间参考信息进行了完整的定义。

表定义Geodatabase 空间几何数据与属性数据保存在同一个表(要素类)中。

拓扑规则Geodatabase 的拓扑关系管理机制在以下几个方面具有明显的优势:(1)用户可自行定义哪些要素类将受拓扑关系规则约束;(2)多个点、线、面要素类(层)可以同时受同一组拓扑关系规则约束;(3)提供了大量的拓扑关系规则;(4)用户为自己的数据可以自行指定必要的拓扑关系规则;(5)拓扑关系及规则是在符合工业标准的DBMS(数据管理系统)中进行管理,可支持多用户并发处理;(6)用户可以局部建立或检查拓扑关系,以提高生产效率。

3、1:M 空间查询的实现原理及应用实例。

答:(1)选择已经建立的地理数据库-Yunnan.mdb,点击右键,在出现的菜单中选择-(2)按照上图显示输入名称,选择公交站点和公交路线,然后下一步(3)当进行到上图时,选择1—M,即一对多。

接着点击下一步。

(4)当进行到如上图时,在两处选择公交站点编号(5)点击“完成”,则完成公交站点到公交路线1—M的关系(6)最后得到如下图所示,可以对1—M关系进行查询4、比较连接(Join)和关联(Link)关系的区别和应用。

(1)区别:连接:连接可以添加额外的属性数据到当前图层,也可以使用这些额外的属性数据进行标注。

GIS实验五 空间数据输出PPT课件

GIS实验五 空间数据输出PPT课件
(2)选择符号(Symbol)选项卡,在Categories上下 拉出现三个选项,分别是Unique Value;Unique Value,Many fields;Match to symbols in a style。其中Unique Value指的是按照一个属性值 来进行分类,Unique Value,Many fields是按照 多个属性值的组合进行分类来确定符号类型,如果 选择Match to symbols in a style的话,将会按照 事先确定的符号类型通过自动匹配来表示属性分类。
15
图层分类符号配置
(3)选择Unique Value选项,在Value Field中选择 CLASS,即道路的分级。
(4)单击“添加全部值”(Add All Values)按钮, 则系统将按“CLASS”字段将对象分类并配置符 号。
(5)到现在为止已经将不同级别的道路进行了分类, 如果对系统默认的符号样式不满,可以单击 Value名称前面的Symbol符号,打开Symbol Selector窗口。通过Option 中的Color,Width 设置改换它的颜色和宽度。也可以单击 Properties按钮改变该符号的一些其他属性,或 者通过单击More Symbols选择更多的符号,从 而得到一幅让自己满意的交通网络图。
13
1、符号配置
图层单一符号配置方法: 在图层控制栏中双击图层符号,在弹出的
符号选择对话框中选择要配置的符号,选 定一个符号后,可以通过该对话框右边的 编辑部分空间对符号进行编辑,可以方便 地进行颜色和大小的编辑。
14
1、符号配置
图层分类符号配置
(1)在道路图层上点右键打开Layer Properties对话框。
3) 确定标注方法Method:Label features in this layer。 4) 在需要标注的字段Text String中选择NAME。 5) 单击确定按钮完成全部要素的标注。

GIS实验报告

GIS实验报告

实验报告GIS应用软件开发专业:测绘工程班级: 10级测绘三班姓名:学号:****:**撰写时间:2013年5月20日星期一目录一、程序运行演示 (2)二、问题及解决方案 (6)三、源程序代码 (7)四、心得体会 (14)一、程序运行演示1.新建项目文件,并实现file中的基本功能,显示地图基本要素。

如图1图12.在工具栏加载按钮,按钮功能是对当前视图缩小3倍;在工具栏加载工具,工具功能在地图上标注当前日期。

如图2图2按钮实现缩小3倍功能操作,如图3图33.点击地图节点,弹出如图4,图5菜单并实现菜单中的内容:图4图54.点击图层节点,弹出如图6菜单并需要实现菜单中的内容图65.点击Legend Class,弹出符号选择对话框,该对话框供用户按需要选择符号并进行更改。

如图7图76.打开图层属性表,用户选择某条记录,可弹出如图8,9所示的右键菜单,并实现右键菜单中的内容图8图9二、问题及解决方案问题1.VS2008与2010之间要进行格式转换,按照所导向的步骤进行,否则程序将无法正常运行,出现错误问题2.构建好基本框架后,地图文档中要素显示出现问题。

此问题要添加licence控件,否则无法显示地图要素。

问题3.使用Toolbar和Toc功能时无法进行操作此问题应在属性设置时建立关联功能。

问题4.程序Program文件中要添加相应功能键语句,否则将无法实现功能。

问题5.引用接口,方法,例如ADF,要添加相应的引用,否则程序出现错误。

问题6.在实现两个自定义按钮与工具时,遇到的问题:先直接引用现有项未实现,发现缺少一些东西,后自己直接创建的Basetool和Basecommand类;在代码中报错,重新生成解决方案后顺利解决这个问题。

问题7.在实现地图和图层节点的右键功能时,遇到琐碎的问题,在这个过程中直接引用老师所给的几个类,但是报错,是因为命名空间未做修改;缺少引用,需要根据错误提示添加相应的引用三、源程序代码using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Runtime.InteropServices;using ESRI.ArcGIS.esriSystem;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.ADF;using ESRI.ArcGIS.SystemUI;using ESRI.ArcGIS.Display;namespace WindowsFormsApplication2{public partial class MainForm : Form{#region class private membersprivate IMapControl3 m_mapControl = null;private string m_mapDocumentName = string.Empty;#endregionIMapDocument m_MapDocument = new MapDocument();#region class constructorprivate ITOCControl2 m_tocControl;private IToolbarMenu m_menuMap;private IToolbarMenu m_menuLayer;private ZoomIn3XCMD1 test = new ZoomIn3XCMD1();public MainForm(){InitializeComponent();}private void newDocumentToolStripMenuItem_Click(object sender, EventArgs e){ICommand command = new CreateNewDocument();command.OnCreate(m_mapControl.Object);command.OnClick();}private void openDocumentToolStripMenuItem_Click(object sender, EventArgs e){openFileDialog1.Title = "Save Map Document As";openFileDialog1.Filter = "Map Documents (*.mxd)|*.mxd";openFileDialog1.ShowDialog();string sFilePath = openFileDialog1.FileName;if (axMapControl1.CheckMxFile(sFilePath)){axMapControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass;axMapControl1.LoadMxFile(sFilePath, 0, Type.Missing);axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;}else{MessageBox.Show(sFilePath + "is not a valid ArcMap document");return;}private void MainForm_Load(object sender, EventArgs e){//get the MapControlm_mapControl = (IMapControl3)axMapControl1.Object;//disable the Save menu (since there is no document yet)this.menuSaveDoc.Enabled = false;//定义地图右键菜单,图层右键菜单m_tocControl = (ITOCControl2)axTOCControl1.Object;m_mapControl = (IMapControl3)axMapControl1.Object;//添加菜单到地图节点m_menuMap = new ToolbarMenu();m_menuMap.AddItem("esriControls.ControlsAdddataCommand", -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);m_menuMap.AddItem(new LayerVisibility(), 1, 1, false, esriCommandStyles.esriCommandStyleTextOnly);m_menuMap.AddItem(new LayerVisibility(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly);//添加菜单到图层节点m_menuLayer = new ToolbarMenu();m_menuLayer.AddItem(new OpenAttributeTableCmd(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);//右键添加属性表m_menuLayer.AddItem(new RemoveLayer(), 1, 1, false, esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(new RemoveLayer(), 1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(new ScaleThresholds(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(new ScaleThresholds(), 3, 4, false, esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(new LayerSelectable(), 1, 5, true, esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(new LayerSelectable(), 2, 6, false, esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(new ZoomToLayer(), -1, 7, true, esriCommandStyles.esriCommandStyleTextOnly);//Set the hook of each menum_menuLayer.SetHook(m_mapControl);m_menuMap.SetHook(m_mapControl);axToolbarControl1.AddItem(test, -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconAndText);axToolbarControl1.AddItem(new AddDateTool(), -1, -1, false, 0,esriCommandStyles.esriCommandStyleIconAndText);}private void saveDocumentToolStripMenuItem_Click(object sender, EventArgs e){//execute Save Document commandif (m_mapControl.CheckMxFile(m_mapDocumentName)){//create a new instance of a MapDocumentIMapDocument mapDoc = new MapDocument();mapDoc.Open(m_mapDocumentName, string.Empty);//Make sure that the MapDocument is not readonlyif (mapDoc.get_IsReadOnly(m_mapDocumentName)){MessageBox.Show("Map document is read only!");mapDoc.Close();return;}//Replace its contents with the current mapmapDoc.ReplaceContents((IMxdContents)m_mapControl.Map);//save the MapDocument in order to persist itmapDoc.Save(esRelativePaths, false);//close the MapDocumentmapDoc.Close();}}#endregionprivate void saveAsToolStripMenuItem_Click(object sender, EventArgs e){//execute SaveAs Document commandICommand command = new ControlsSaveAsDocCommand();command.OnCreate(m_mapControl);command.OnClick();}private void exitToolStripMenuItem_Click(object sender, EventArgs e){Application.Exit();}private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e){statusBarXY.Text = string.Format("{0}, {1} {2}", e.mapX.ToString("#######.##"), e.mapY.ToString("#######.##"), axMapControl1.MapUnits.ToString().Substring(4));}private void axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e){test.m_activeView = this.axMapControl1.ActiveView;//添加两个工具时添加//get the current document name from the MapControlm_mapDocumentName = m_mapControl.DocumentFilename;//if there is no MapDocument, diable the Save menu and clear the statusbarif (m_mapDocumentName == string.Empty){menuSaveDoc.Enabled = false;statusBarXY.Text = string.Empty;}else{//enable the Save manu and write the doc name to the statusbarmenuSaveDoc.Enabled = true;statusBarXY.Text = Path.GetFileName(m_mapDocumentName);}}private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e){if (e.button == 1){//IBasicMap map = new Map();IMap Map = new Map();IBasicMap map = (IBasicMap)Map;ILayer layer = new FeatureLayer();object other = new object();object index = new object();esriTOCControlItem item = new esriTOCControlItem();//Determine what kind of item has been clicked onaxTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);//QI to IFeatureLayer and IGeoFeatuerLayer interfaceif (layer == null) return;IFeatureLayer featureLayer = layer as IFeatureLayer;if (featureLayer == null) return;IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer;ILegendClass legendClass = new LegendClass();ISymbol symbol = null;if (other is ILegendGroup && (int)index != -1){legendClass = ((ILegendGroup)other).get_Class((int)index);symbol = legendClass.Symbol;}if (symbol == null) return;symbol = GetSymbolByControl(symbol);//symbol = GetSymbolBySymbolSelector(symbol);if (symbol == null) return;legendClass.Symbol = symbol;this.Activate();//Fire contents changed event that the TOCControl listens toaxMapControl1.ActiveView.ContentsChanged();//Refresh the displayaxMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);axTOCControl1.Update();}if (e.button == 2){esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;IBasicMap map = null; ILayer layer = null;object other = null; object index = null;//Determine what kind of item is selectedm_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);//Ensure the item gets selectedif (item == esriTOCControlItem.esriTOCControlItemMap)m_tocControl.SelectItem(map, null);elsem_tocControl.SelectItem(layer, null);// Set the layer into the CustomProperty (this is used by the custom layer commands)m_mapControl.CustomProperty = layer;//Popup the correct context menuif (item == esriTOCControlItem.esriTOCControlItemMap) m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd);if (item == esriTOCControlItem.esriTOCControlItemLayer) m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);}}private ISymbol GetSymbolByControl(ISymbol symbolType){ISymbol symbol = null;IStyleGalleryItem styleGalleryItem = null;esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassMarkerSymbols;if (symbolType is IMarkerSymbol){styleClass = esriSymbologyStyleClass.esriStyleClassMarkerSymbols;}if (symbolType is ILineSymbol){styleClass = esriSymbologyStyleClass.esriStyleClassLineSymbols;}if (symbolType is IFillSymbol){styleClass = esriSymbologyStyleClass.esriStyleClassFillSymbols;}GetSymbolByControlForm symbolForm = new GetSymbolByControlForm(styleClass);symbolForm.ShowDialog();styleGalleryItem = symbolForm.m_styleGalleryItem;if (styleGalleryItem == null) return null;symbol = styleGalleryItem.Item as ISymbol;symbolForm.Dispose();this.Activate();return symbol;}}}四、心得体会本次实验过程中,值得肯定的是,已对AO开发一般流程基本掌握:新建项目、搭建框架、实现各个框架中的各个功能、添加引用与类。

【精品】PPT课件 地理信息系统实验共55页

【精品】PPT课件  地理信息系统实验共55页
33、如果惧怕前面跌宕的山岩,生命 就永远 只能是 死水一 潭。 34、当你眼泪忍不住要流出来的时候 ,睁大 眼睛, 千万别 眨眼!你会看到 世界由 清晰变 模糊的 全过程 ,心会 在你泪 水落下 的那一 刻变得 清澈明 晰。盐 。注定 要融化 的,也 许是用 眼泪的 方式。
35、不要以为自己成功一次就可以了 ,也不 要以为 过去的 光荣可 以被永 远肯定 。
【精品】PPT课件 地理信 息系统实验
31、别人笑我太疯癫,我笑他人看不 穿。(名 言网) 32、我不想听失意者的哭泣,抱怨者 的牢骚 ,这是 羊群中 的瘟疫 ,我不 能被它 传染。 我要尽 量避免 绝望, 辛勤耕 耘,忍 受苦楚 。我一 试再试 ,争取 每天的 成功, 避免以 失败收 常在别 人停滞 不前时 ,我继 。 ——德 谟克利 特 67、今天应做的事没有做,明天再早也 是耽误 了。——裴斯 泰洛齐 68、决定一个人的一生,以及整个命运 的,只 是一瞬 之间。 ——歌 德 69、懒人无法享受休息之乐。——拉布 克 70、浪费时间是一桩大罪过。——卢梭

地理信息系统实验PPT课件

地理信息系统实验PPT课件
第33页/共53页
23.在‘Theme menu’中选‘Select By Theme’选择离亚特兰大300英里的城 市。
第34页/共53页
24.选择‘Are Within Distance Of’ 再输入300英里。点击‘New Set’。
第35页/共53页
25.这样黄色的点就代表离亚特兰大 距离300英里的城市。
第8页/共53页
出现以下窗口:
双 击
第9页/共53页
结果如下:
其他要素可作类似修改,使得地图更美观。
第10页/共53页
Arcview练习(二)
第11页/共53页
1.按照练习1的方法打开Arcview,选择United States,打开。
第12页/共53页
第13页/apr。
第50页/共53页
12.再打开Theme Table,黄色的就是 百货商店。
第51页/共53页
13.选择表中的Sales字段名,再点击排序 按钮,最后点击提升按钮,前五位即为销 售量最高的百货商店
第52页/共53页
感谢您的观看!
第53页/共53页
(New)按钮,ArcView便自动生成一个新的空白的专题 地图。
第3页/共53页
专题地图的重命名
• 有两种方法: 1、是先单击选中Layout列表中想要换名的专题图,然后从
“Project”下拉菜单中点选“换名”(Rename),再在弹 出的对话框内输入新的专题图名称,“OK”确定后,换名完 成。
第22页/共53页
12.在中‘Classification Field’选择 ‘Total’,在‘Color Ramps’选择 ‘Greens to Oranges dichromatic’,然 后倒转颜色代表的销售额。
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

实验报告GIS应用软件开发专业:测绘工程班级:10 级测绘三班姓名:学号:****:**撰写时间:2013 年5 月20 日星期一目录一、程序运行演示 (2)二、问题及解决方案 (6)三、源程序代码 (7)四、心得体会 (14)一、程序运行演示1. 新建项目文件,并实现file 中的基本功能,显示地图基本要素。

如图 1图12. 在工具栏加载按钮,按钮功能是对当前视图缩小 3 倍;在工具栏加载工具,工具功能在地图上标注当前日期。

如图 2图2按钮实现缩小 3 倍功能操作,如图 3图33.点击地图节点,弹出如图4,图5 菜单并实现菜单中的内容:图4图54. 点击图层节点,弹出如图 6 菜单并需要实现菜单中的内容图65. 点击Legend Class ,弹出符号选择对话框,该对话框供用户按需要选择符号并进行更改。

如图7图76.打开图层属性表,用户选择某条记录,可弹出如图8,9 所示的右键菜单,并实现右键菜单中的内容图8图9二、问题及解决方案问题1.VS2008 与2010 之间要进行格式转换,按照所导向的步骤进行,否则程序将无法正常运行,出现错误问题2. 构建好基本框架后,地图文档中要素显示出现问题。

此问题要添加licence 控件,否则无法显示地图要素。

问题3. 使用Toolbar 和Toc功能时无法进行操作此问题应在属性设置时建立关联功能。

问题4. 程序Program文件中要添加相应功能键语句,否则将无法实现功能。

问题5. 引用接口,方法,例如ADF,要添加相应的引用,否则程序出现错误。

问题6. 在实现两个自定义按钮与工具时,遇到的问题:先直接引用现有项未实现,发现缺少一些东西,后自己直接创建的Basetool 和Basecomman类d ;在代码中报错,重新生成解决方案后顺利解决这个问题。

问题7. 在实现地图和图层节点的右键功能时,遇到琐碎的问题,在这个过程中直接引用老师所给的几个类,但是报错,是因为命名空间未做修改;缺少引用,需要根据错误提示添加相应的引用三、源程序代码using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Runtime.InteropServices;using ESRI.ArcGIS.esriSystem;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.ADF;using ESRI.ArcGIS.SystemUI;using ESRI.ArcGIS.Display;namespace WindowsFormsApplication2{public partial class MainForm : Form{#region class private membersprivate IMapControl3 m_mapControl = null;private string m_mapDocumentName = string.Empty;#endregionIMapDocument m_MapDocument = new MapDocument();#region class constructorprivate ITOCControl2 m_tocControl;private IToolbarMenu m_menuMap;private IToolbarMenu m_menuLayer;private ZoomIn3XCMD1 test = new ZoomIn3XCMD1();public MainForm(){InitializeComponent();}private void newDocumentToolStripMenuItem_Click(object sender, EventArgs e){ICommand command = new CreateNewDocument();command.OnCreate(m_mapControl.Object);command.OnClick();}private void openDocumentToolStripMenuItem_Click(object sender, EventArgs e){openFileDialog1.Title = "Save Map Document As";openFileDialog1.Filter = "Map Documents (*.mxd)|*.mxd";openFileDialog1.ShowDialog();string sFilePath = openFileDialog1.FileName;if (axMapControl1.CheckMxFile(sFilePath)){axMapControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass;axMapControl1.LoadMxFile(sFilePath, 0, Type.Missing);axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;}else{MessageBox.Show(sFilePath + "is not a valid ArcMap document");return;}}private void MainForm_Load(object sender, EventArgs e){//get the MapControlm_mapControl = (IMapControl3)axMapControl1.Object;//disable the Save menu (since there is no document yet)this.menuSaveDoc.Enabled = false;// 定义地图右键菜单,图层右键菜单m_tocControl = (ITOCControl2)axTOCControl1.Object;m_mapControl = (IMapControl3)axMapControl1.Object;// 添加菜单到地图节点m_menuMap = new ToolbarMenu();m_menuMap.AddItem("esriControls.ControlsAdddataCommand", -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);m_menuMap.AddItem(new LayerVisibility(), 1, 1, false, esriCommandStyles.esriCommandStyleTextOnly);m_menuMap.AddItem(new LayerVisibility(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly);// 添加菜单到图层节点m_menuLayer = new ToolbarMenu();m_menuLayer.AddItem(new OpenAttributeTableCmd(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);// 右键添加属性表m_menuLayer.AddItem(new RemoveLayer(), 1, 1, false, esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(new RemoveLayer(), 1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(new ScaleThresholds(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(new ScaleThresholds(), 3, 4, false, esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(new LayerSelectable(), 1, 5, true, esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(new LayerSelectable(), 2, 6, false, esriCommandStyles.esriCommandStyleTextOnly);m_menuLayer.AddItem(new ZoomToLayer(), -1, 7, true, esriCommandStyles.esriCommandStyleTextOnly);//Set the hook of each menum_menuLayer.SetHook(m_mapControl);m_menuMap.SetHook(m_mapControl);axToolbarControl1.AddItem(test, -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconAndText);axToolbarControl1.AddItem(new AddDateTool(), -1, -1, false, 0,esriCommandStyles.esriCommandStyleIconAndText);}private void saveDocumentToolStripMenuItem_Click(object sender, EventArgs e){//execute Save Document commandif (m_mapControl.CheckMxFile(m_mapDocumentName)){//create a new instance of a MapDocumentIMapDocument mapDoc = new MapDocument();mapDoc.Open(m_mapDocumentName, string.Empty);//Make sure that the MapDocument is not readonlyif (mapDoc.get_IsReadOnly(m_mapDocumentName)){MessageBox.Show("Map document is read only!");mapDoc.Close();return;}//Replace its contents with the current mapmapDoc.ReplaceContents((IMxdContents)m_mapControl.Map);//save the MapDocument in order to persist itmapDoc.Save(esRelativePaths, false);//close the MapDocumentmapDoc.Close();}}#endregionprivate void saveAsToolStripMenuItem_Click(object sender, EventArgs e){//execute SaveAs Document commandICommand command = new ControlsSaveAsDocCommand();command.OnCreate(m_mapControl);command.OnClick();}private void exitToolStripMenuItem_Click(object sender, EventArgs e){Application.Exit();}private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e){statusBarXY.Text =string.Format("{0}, {1} {2}", e.mapX.ToString("#######.##"),e.mapY.ToString("#######.##"), axMapControl1.MapUnits.ToString().Substring(4));}private void axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e){test.m_activeView = this.axMapControl1.ActiveView;// 添加两个工具时添加//get the current document name from the MapControlm_mapDocumentName = m_mapControl.DocumentFilename;//if there is no MapDocument, diable the Save menu and clear the statusbarif (m_mapDocumentName == string.Empty){menuSaveDoc.Enabled = false;statusBarXY.Text = string.Empty;}else{//enable the Save manu and write the doc name to the statusbarmenuSaveDoc.Enabled = true;statusBarXY.Text = Path.GetFileName(m_mapDocumentName);}}private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e){if (e.button == 1){//IBasicMap map = new Map();IMap Map = new Map();IBasicMap map = (IBasicMap)Map;ILayer layer = new FeatureLayer();object other = new object();object index = new object();esriTOCControlItem item = new esriTOCControlItem();//Determine what kind of item has been clicked onaxTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);//QI to IFeatureLayer and IGeoFeatuerLayer interfaceif (layer == null) return;IFeatureLayer featureLayer = layer as IFeatureLayer;if (featureLayer == null) return;IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer;ILegendClass legendClass = new LegendClass();ISymbol symbol = null;if (other is ILegendGroup && (int)index != -1){legendClass = ((ILegendGroup)other).get_Class((int)index);symbol = legendClass.Symbol;}if (symbol == null) return;symbol = GetSymbolByControl(symbol);//symbol = GetSymbolBySymbolSelector(symbol);if (symbol == null) return;legendClass.Symbol = symbol;this.Activate();//Fire contents changed event that the TOCControl listens toaxMapControl1.ActiveView.ContentsChanged();//Refresh the displayaxMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);axTOCControl1.Update();}if (e.button == 2){esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;IBasicMap map = null; ILayer layer = null;object other = null; object index = null;//Determine what kind of item is selectedm_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);//Ensure the item gets selectedif (item == esriTOCControlItem.esriTOCControlItemMap)m_tocControl.SelectItem(map, null);elsem_tocControl.SelectItem(layer, null);// Set the layer into the CustomProperty (this is used by the custom layer commands)m_mapControl.CustomProperty = layer;//Popup the correct context menuif (item == esriTOCControlItem.esriTOCControlItemMap)m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd);if (item == esriTOCControlItem.esriTOCControlItemLayer)m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);}}private ISymbol GetSymbolByControl(ISymbol symbolType){ISymbol symbol = null;IStyleGalleryItem styleGalleryItem = null;esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassMarkerSymbols;if (symbolType is IMarkerSymbol){styleClass = esriSymbologyStyleClass.esriStyleClassMarkerSymbols;}if (symbolType is ILineSymbol){styleClass = esriSymbologyStyleClass.esriStyleClassLineSymbols;}if (symbolType is IFillSymbol){styleClass = esriSymbologyStyleClass.esriStyleClassFillSymbols;}GetSymbolByControlForm symbolForm = new GetSymbolByControlForm(styleClass);symbolForm.ShowDialog();styleGalleryItem = symbolForm.m_styleGalleryItem;if (styleGalleryItem == null) return null;symbol = styleGalleryItem.Item as ISymbol;symbolForm.Dispose();this.Activate();return symbol;}}}四、心得体会本次实验过程中,值得肯定的是,已对AO开发一般流程基本掌握:新建项目、搭建框架、实现各个框架中的各个功能、添加引用与类。

相关文档
最新文档