东华理工GIS二次开发实验报告
更新时间:2023-06-08 17:32:01 阅读量: 实用文档 文档下载
- GIS二次开发实验推荐度:
- 相关推荐
GIS
二次开发实验报告学号: 姓 名: 班 级: 专 业: 指导老师:
二零一五年1月4日
目录
1
实验一:软件安装与AOI书签开发 .................................................................... 1 1.1 1.2 1.3 2
实验目的.......................................................................................................... 1 实验内容.......................................................................................................... 1 实验结果.......................................................................................................... 1
实验二:地图数据组织与访问 ............................................................................ 8 2.1 2.2 2.3
实验目的.......................................................................................................... 8 实验内容.......................................................................................................... 8 实验结果.......................................................................................................... 8
3 实验三:地图渲染与制图输出 ........................................................................ 133 3.1 3.2 3.3
实验目的...................................................................................................... 133 实验内容...................................................................................................... 133 实验结果...................................................................................................... 133
4 实验四:空间数据处理 .................................................................................... 188 4.1 4.2 4.3
实验目的...................................................................................................... 188 实验内容...................................................................................................... 188 实验结果...................................................................................................... 188
5 实验五:GIS分析 .............................................................................................. 189 5.1 5.2 5.3
实验目的...................................................................................................... 189 实验内容...................................................................................................... 189 实验结果...................................................................................................... 189
6 实验六:栅格数据处理 ...................................................................................... 24 6.1 6.2 6.3
实验目的........................................................................................................ 24 实验内容........................................................................................................ 24 实验结果........................................................................................................ 25
7 实验总结 .............................................................................................................. 28
1 实验一:软件安装与AOI书签开发
1.1 实验目的
掌握ArcGIS Engine开发环境的相关软件安装 掌握AOI书签程序开发
1.2 实验内容
安装Visual Studio 2010
安装Microsoft .NET Framework 3.5 安装ArcGIS Engine 10.1
安装ArcObjects Developer kit For Microsoft .NET Framework 10.1 安装ArcGIS License Manager,并授权 实现AOI书签的创建 实现AOI书签的调用
1.3 实验步骤与结果
安装VS2010
安装AE 10.0
打开VS 2010 选择ArcGIs—Extending ArcObjects—MapControl Application
打开界面如图所示
给窗体添加一个书签窗体
输入如下代码
C# Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
using System;
using System.Collections.Generic; using ponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System.Windows.Forms;
namespace MapControlApplication1 {
public partial class admitBookmarkName : Form {
public admitBookmarkName(MainForm frm) { InitializeComponent(); if (frm != null) {
m_frmMain = frm; } }
public MainForm m_frmMain;
private void 确定_Click(object sender, EventArgs e) {
if (m_frmMain != null && tbbookmarkname.Text != "") m_frmMain.creatbookmark(tbbookmarkname.Text); this.Close(); } } }
输入如下代码,用来添加书签
C# Code 1 2
3 4 5 6 7 8 9 10 11 12 13
public void creatbookmark(string sbookmarkname) {
IAOIBookmark aoibookmark = new AOIBookmarkClass(); if (aoibookmark != null) {
aoibookmark.Location = axMapControl1.ActiveView.Extent; = sbookmarkname; }
IMapBookmarks bookmarks = axMapControl1.Map as IMapBookmarks; if (bookmarks != null)
bookmarks.AddBookmark(aoibookmark);
跳转书签ToolStripMenuItem.DropDownItems.Add(); }
C# Code 1 2
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
private void 跳转书签ToolStripMenuItem_DropDownItemClicked (object sender, ToolStripItemClickedEventArgs e) {
IMapBookmarks bookmarks = axMapControl1.Map as IMapBookmarks; IEnumSpatialBookmark enumbookmark = bookmarks.Bookmarks; enumbookmark.Reset();
ISpatialBookmark spabookmark = enumbookmark.Next(); while (spabookmark != null)
{ if (e.ClickedItem.ToString() == ) {
spabookmark.ZoomTo((IMap)axMapControl1.ActiveView); axMapControl1.ActiveView.Refresh(); break; }
spabookmark = enumbookmark.Next(); } }
运行程序,如图方式添加书签
查看已添加书签并点击跳转
2 实验二:地图数据组织与访问
2.1 实验目的
了解ArcGIS Engine中地图数据的组织结构 掌握ArcGIS Engine地图数据访问方法
2.2 实验内容
编写“数据操作”类
利用DataGridView控件展示Continents图层的序号和名称字段
2.3 实验步骤与结果
添加dataoperator类,代码如下
C# Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
using System;
using System.Collections.Generic; using System.Linq; using System.Text; using System.Data;
using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.ADF; using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Geometry; using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.DataSourcesFile; using ESRI.ArcGIS.Geodatabase; namespace MapControlApplication1 {
class dataoperator {
public IMap mmap;
public dataoperator(IMap map)
21 {
22 mmap = map; 23 }
24 public ILayer getlayerbyname(string slayername) 25 {
26 if (slayername == "" || mmap == null) return null; 27 for (int i = 0; i < yerCount; i++) 28 if (mmap.get_Layer(i).Name == slayername) 29
31 } 32
33 public IFeatureClass createshapefile
34 (string sparentdirection, string sworkspc, string sfilename) 35 {
36 if (System.IO.Directory.Exists(sparentdirection + sworkspc)) 37 System.IO.Directory.Delete(sparentdirection + sworkspc, true); 38 IWorkspaceFactory workspacef = 39
new ShapefileWorkspaceFactoryClass();
40 IWorkspaceName workname; 41 workname = 42
workspacef.Create(sparentdirection, sworkspc, null, 0);
43 IName name = workname as IName;
44 IWorkspace workspace = (IWorkspace)name.Open(); 45 IFeatureWorkspace ftworkspace = 46
workspace as IFeatureWorkspace;
47 IFields fields = new FieldsClass();
48 IFieldsEdit fieldsedit = fields as IFieldsEdit; 49 IFieldEdit fedit = new FieldClass(); 50 _2 = "OID"; 51 fedit.AliasName_2 = "序号";
52 fedit.Type_2 = esriFieldType.esriFieldTypeOID; 53 fieldsedit.AddField((IField)fedit); 54 fedit = new FieldClass(); 55 _2 = "Name"; 56 fedit.AliasName_2 = "名称";
57 fedit.Type_2 = esriFieldType.esriFieldTypeString; 58 fieldsedit.AddField((IField)fedit);
59 IGeometryDefEdit geodefedit = new GeometryDefClass(); 60 ISpatialReference sparef = mmap.SpatialReference; 61 geodefedit.SpatialReference_2 = sparef; 62 geodefedit.GeometryType_2 = 63
esriGeometryType.esriGeometryPoint;
64 fedit = new FieldClass();
return mmap.get_Layer(i);
30 return null;
65 string shapefilename = "Shape"; 66 _2 = shapefilename; 67 fedit.AliasName_2 = "形状";
68 fedit.Type_2 = esriFieldType.esriFieldTypeGeometry; 69 fedit.GeometryDef_2 = geodefedit; 70 fieldsedit.AddField((IField)fedit); 71
72 IFeatureClass ftclass;
73 ftclass = ftworkspace.CreateFeatureClass 74 (sfilename, fields, null, null, 75
esriFeatureType.esriFTSimple, "Shape", "");
76 if (ftclass == null) 77 return null; 78 return ftclass; 79 } 80
81 public bool addfeaturetomap 82
83 {
84 if (ftclass == null || slayername == null) 85 return false;
86 IFeatureLayer ftlayer = new FeatureLayerClass(); 87 ftlayer.FeatureClass = ftclass; 88 = slayername; 89 mmap.AddLayer(ftlayer as ILayer); 90 IActiveView act = mmap as IActiveView; 91 act.Refresh(); 92 return true; 93 } 94
95 public DataTable getcontNames() 96 {
97 ILayer layer = getlayerbyname("Continents");
98 IFeatureLayer featurelayer = layer as IFeatureLayer; 99 if (featurelayer == null) 100 return null; 101 IFeature feature;
102 IFeatureCursor featureCursor = featurelayer.Search(null, false); 103 feature = featureCursor.NextFeature(); 104 if(feature == null) 105 return null;
106 DataTable datatable = new DataTable(); 107 DataColumn datacolum = new DataColumn(); 108 datacolum.ColumnName = "序号";
(IFeatureClass ftclass, string slayername)
109 datacolum.DataType = System.Type.GetType("System.String"); 110
datatable.Columns.Add(datacolum); 111 datacolum = new DataColumn(); 112 datacolum.ColumnName = "名称";
113 datacolum.DataType = System.Type.GetType("System.String"); 114 datatable.Columns.Add(datacolum); 115 DataRow datarow; 116 while(feature != null) 117 {
118 datarow = datatable.NewRow(); 119 datarow[0] = feature.get_Value(0); 120 datarow[1] = feature.get_Value(2); 121 datatable.Rows.Add(datarow);
122 feature = featureCursor.NextFeature(); 123 }
124 return datatable; 125 } 126 } 127 }
新建databord窗体
主窗体新建菜单“空间数据”,并添加如下代码
C# Code
1 private void 访问图层数据ToolStripMenuItem_Click(object sender, EventArgs e) 2
{
3 dataoperator Dataoperate = new dataoperator(axMapControl1.Map); 4 databoard databoard = 5
}
new databoard("各大洲州名", Dataoperate.getcontNames());
6 databoard.Show();
点击“空间数据”得到空间数据表
3 实验三:地图渲染与制图输出
3.1 实验目的
了解地图符号的分类与可视化过程 掌握地图符号的渲染方法
3.2 实验内容
编写“地图编制”类,添加成员函数 实现获取地图渲染器信息功能 实现地图的简单符号渲染
3.3 实验步骤
C# Code
1 private void 简单渲染图层ToolStripMenuItem1_Click(object sender, EventArgs e) 2 {
3 dataoperator dataOperator = new dataoperator(axMapControl1.Map); 4 ILayer layer = dataOperator.getlayerbyname("World Cities"); 5 IRgbColor rgbColor = new RgbColorClass(); 6 rgbColor.Blue = 0; 7 rgbColor.Red = 255; 8 rgbColor.Green = 0;
9 IColor color = rgbColor as IColor;
10 ISymbol symbol = MapComposer.getsymbolfromlayer(layer); 11 bool res = MapComposer.RenderSimply(layer, color);
12 if(res) 13 {
14 axMapControl1.ActiveView.ContentsChanged(); 15 axMapControl1.ActiveView.Refresh();
16 简单渲染图层ToolStripMenuItem.Enabled = false; 17 } 18 else 19 {
20 MessageBox.Show("简单渲染图层失败"); 21 } 22 }
主窗体新建渲染图层菜单,并新建子菜单
C# Code
1 private void 获取渲染器信息ToolStripMenuItem_Click(object sender, EventArgs e) 2 {
3 dataoperator dataOperator = new dataoperator(axMapControl1.Map); 4 ILayer layer = dataOperator.getlayerbyname("World Cities"); 5 MessageBox.Show(MapComposer.getrendertypebylayer(layer)); 6 }
新建MapComposer类并输入以下代码 C# Code
1 using System;
2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text;
5 using ESRI.ArcGIS.esriSystem; 6 using ESRI.ArcGIS.Carto;
7 using ESRI.ArcGIS.Controls; 8 using ESRI.ArcGIS.ADF; 9 using ESRI.ArcGIS.SystemUI; 10 using ESRI.ArcGIS.Geometry; 11 using ESRI.ArcGIS.Display; 12 using ESRI.ArcGIS.Geodatabase;
13 namespace MapControlApplication1 14 {
15 class MapComposer 16 {
17 public static string getrendertypebylayer(ILayer layer) 18 {
19 if(layer == null) 20 return "获取失败";
21 IFeatureLayer ftly = (IFeatureLayer)layer; 22 IGeoFeatureLayer gftly = (IGeoFeatureLayer)layer; 23 IFeatureRenderer ftren = gftly.Renderer; 24 if(ftren is ISimpleRenderer) 25 return "ISimpleRenderer";
26 else if(ftren is IUniqueValueRenderer) 27 return "IUniqueValueRenderer"; 28 else if(ftren is IDotDensityRenderer) 29 return "IDotDensityRenderer"; 30 else if(ftren is IChartRenderer) 31 return "IChartRenderer";
32 else if(ftren is IProportionalSymbolRenderer) 33 return "IProportionalSymbolRenderer"; 34 return "未知或者获取渲染器失败"; 35 }
36 public static ISymbol getsymbolfromlayer(ILayer layer) 37 {
38 if(layer == null) 39 return null;
40 IFeatureLayer ftly = (IFeatureLayer)layer; 41 IFeatureCursor ftcs = ftly.Search(null, false); 42 IFeature ft = ftcs.NextFeature(); 43 if(ft == null) 44 return null;
45 IGeoFeatureLayer gftly = ftly as IGeoFeatureLayer; 46 IFeatureRenderer ftren = gftly.Renderer; 47 if(ftren == null) 48 return null;
49 ISymbol syb = ftren.get_SymbolByFeature(ft); 50 return syb; 51 }
52 public static bool RenderSimply(ILayer layer, IColor color) 53 {
54 if(layer == null || color == null) 55 return false;
56 ISymbol symbol = getsymbolfromlayer(layer);
57 if(symbol == null) 58 return false;
59 IFeatureLayer featureLayer = layer as IFeatureLayer; 60 IFeatureClass featureClass = featureLayer.FeatureClass; 61 if(featureClass == null) 62 return false;
63 esriGeometryType geoType = featureClass.ShapeType; 64 switch(geoType) 65 {
66 case esriGeometryType.esriGeometryPoint: 67 {
68 IMarkerSymbol markerSymbol = symbol as IMarkerSymbol; 69 markerSymbol.Color = color; 70 break; 71 }
72 case esriGeometryType.esriGeometryMultipoint: 73 {
74 IMarkerSymbol markerSymbol = symbol as IMarkerSymbol; 75 break; 76 }
77 case esriGeometryType.esriGeometryPolyline: 78 {
79 ISimpleLineSymbol simpleLineSymbol = 80
symbol as ISimpleLineSymbol;
81 simpleLineSymbol.Color = color; 82 break; 83 }
84 case esriGeometryType.esriGeometryPolygon: 85 {
86 IFillSymbol fillSymbol = symbol as IFillSymbol; 87 fillSymbol.Color = color; 88 break; 89 } 90 default:
91 return false; 92 }
93 ISimpleRenderer simpleRenderer = new SimpleRendererClass(); 94 simpleRenderer.Symbol = symbol; 95 IFeatureRenderer featureRenderer = 96
simpleRenderer as IFeatureRenderer;
97 if(featureRenderer == null) 98 return false;
99 IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer;
geoFeatureLayer.Renderer = featureRenderer; return true; }
} }
运行“获取渲染器信息”
运行“简单渲染器渲染”
4 实验四:空间数据处理
4.1 实验目的
了解创建空间数据的过程 掌握创建空间数据的方法
4.2 实验内容
实现创建Shapefile文件的程序 实现新增点要素程序
4.3 实验步骤与结果
主窗体添加“添加shapefile”菜单
C# Code
1 private void 添加shapefileToolStripMenuItem_Click(object sender, EventArgs e) 2 {
3 dataoperator dtoprt = new dataoperator(axMapControl1.Map); 4 IFeatureClass ftclss = 5 6 ;
7 if(ftclss == null) 8 {
9 MessageBox.Show("创建失败"); 10 return; 11 }
12 bool bres = dtoprt.addfeaturetomap(ftclss, "observation"); 13 if(bres) 14 {
15 添加shapefileToolStripMenuItem.Enabled = false; 16 return; 17 } 18 else
19 MessageBox.Show("出错了!"); 20 return; 21 }
dtoprt.createshapefile("C:\\", "shapefileworkspace", "shapefileSample")
5 实验五:GIS分析
5.1 实验目的
了解GIS空间分析的内容 掌握空间关系查询方法 掌握空间拓扑分析方法 掌握空间数据统计方法
5.2 实验内容
实现空间关系查询程序 实现缓冲区分析程序 实现要素统计程序
正在阅读:
东华理工GIS二次开发实验报告06-08
天津市浔兴拉链科技有限公司07-20
人教版高中地理必修一第二章第三节学案12-08
记一次挣钱的经历作文500字06-20
中国关工委儿发中心天赋亲职教育《帮孩子成为学习赢家》课题组介06-07
2007江苏省宝应县中学高中学业水平测试模拟试卷(新人教)政治10-16
婴幼儿营养与保育形考作业答案04-30
我的读书生活作文800字02-04
融资担保公司薪酬制度05-07
- 教学能力大赛决赛获奖-教学实施报告-(完整图文版)
- 互联网+数据中心行业分析报告
- 2017上海杨浦区高三一模数学试题及答案
- 招商部差旅接待管理制度(4-25)
- 学生游玩安全注意事项
- 学生信息管理系统(文档模板供参考)
- 叉车门架有限元分析及系统设计
- 2014帮助残疾人志愿者服务情况记录
- 叶绿体中色素的提取和分离实验
- 中国食物成分表2020年最新权威完整改进版
- 推动国土资源领域生态文明建设
- 给水管道冲洗和消毒记录
- 计算机软件专业自我评价
- 高中数学必修1-5知识点归纳
- 2018-2022年中国第五代移动通信技术(5G)产业深度分析及发展前景研究报告发展趋势(目录)
- 生产车间巡查制度
- 2018版中国光热发电行业深度研究报告目录
- (通用)2019年中考数学总复习 第一章 第四节 数的开方与二次根式课件
- 2017_2018学年高中语文第二单元第4课说数课件粤教版
- 上市新药Lumateperone(卢美哌隆)合成检索总结报告
- 东华
- 理工
- 实验
- 报告
- 开发
- GIS
- 人教版五年级数学下册第三单元_体积单位间的进率
- 2013奥巴马就职演说中英对照全文
- 2.5.2等比数列前n项和的性质
- 两招小办法对付宝宝发烧
- 2015山东公务员考试行测备考:三段论解题技巧
- 阿扎司琼防治呕吐的护理体会
- 公共基础知识哲学
- 综述与讲座医学影像检查在胸部疾病诊断中的应用
- 必修1第一章集合单元练习题
- “面包与水仙花”新材料作文讲评
- 第5章 国际货物运输保险
- 周期问题(三年级奥数)
- ICN- seeing the forest for the trees
- 北京艺术考察报告
- 公司活动团队游戏大全
- Tecplot 常用数据格式(转)
- 如何去除页眉页脚(注:是完全清除,不是删除里面内容的那种)
- 特种设备安全事故应急预案
- 深圳职业技术学院工业设计专业建设方案
- 2016-2021年卡规产业市场发展及前景预测研究报告