• ArcGis课程设计


    这是上大学的时候熬了几个通宵写出来的课程设计,放在旧电脑里面很久很久了,觉得不能浪费了,想着整理整理放在这,为曾经奋斗过的夜留个纪念。可能对于大佬们来说这个很简单。我记得我们这个课设分成了论文类题目(6题)、制作工具类题目(9题)和应用系统类题目(2题),工具类和应用系统类要求提交源程序和打印的报告,好死不死我正好抽中了应用系统类题目。具体的某个细节想不起来了,只记得是deadline当天写完的,结果去演示的时候老师没看几眼就全部打回让我重做,差点哭死我。又熬了一晚上终于完成。

    前期准备

    • visual studio
    • 安装ArcGIS engine

    上课笔记

    1. public staticBitmap RGB2Gray(Bitmap srcBitmap)
    2. 提取像素法
    3. {
    4. Color srcColor;
    5. int wide = srcBitmap.Width;
    6. int height = srcBitmap.Height;
    7. for (int y = 0; y < height; y++)
    8. for (int x = 0; x < wide; x++)
    9. {
    10. //获取像素的RGB颜色值
    11. srcColor = srcBitmap.GetPixel(x, y);
    12. byte temp = (byte)(srcColor.R * .299 + srcColor.G * .587 + srcColor.B * .114);
    13. //设置像素的RGB颜色值
    14. srcBitmap.SetPixel(x, y, Color.FromArgb(temp, temp, temp));
    15. }
    16. return srcBitmap ;
    17. }
    18. (2) 内存法
    19. if (curBitmap != null)
    20. {
    21. int width = curBitmap.Width;
    22. int height = curBitmap.Height;
    23. int length = height * 3 * width;
    24. RGB = new byte[length];
    25. BitmapData data = curBitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
    26. 三、对图片进行缩放
    27. System.Drawing.Image drawimage = System.Drawing.Image.FromFile(photopath);
    28. Bitmap imgOutput = new Bitmap(drawimage,60,30);
    29. imgOutput.Save(newphotppath, System.Drawing.Imaging.ImageFormat.Jpeg);
    30. imgOutput.Dispose();
    31. Response.End();
    32. System.IntPtr Scan0 = data.Scan0;
    33. System.Runtime.InteropServices.Marshal.Copy(Scan0, RGB, 0, length);
    34. double gray = 0;
    35. for (int i = 0; i < RGB.Length; i=i+3)
    36. {
    37. gray = RGB[i + 2] * 0.3 + RGB[i + 1] * 0.59 + RGB[i] * 0.11;
    38. RGB[i + 2] = RGB[i + 1] = RGB[i] = (byte)gray;
    39. }
    40. System.Runtime.InteropServices.Marshal.Copy(RGB, 0, Scan0, length);
    41. curBitmap.UnlockBits(data);
    42. }
    43. private void pictureBox1_Paint(object sender, PaintEventArgs e)
    44. {
    45. if (b == false) return;
    46. Graphics g = e.Graphics;
    47. Pen p = new Pen(Color.Red, 2);
    48. g.DrawLine(p, 0, 0, 100, 100);
    49. /* Bitmap bmp = new Bitmap("test1.bmp");
    50. pictureBox1.Image = bmp;
    51. Color pixelColor = bmp.GetPixel(50, 50);
    52. SolidBrush pixelBrush = new SolidBrush(pixelColor);
    53. e.Graphics.FillRectangle(pixelBrush, 0, 0, 100, 100);*/
    54. }
    55. //地图制图
    56. 1.添加图名、比例尺、指北针等地图元素
    57. MapSurrround对象:Legend图例、ScaleBar比例尺、MapTitle图名
    58. 2.打印地图
    59. Map
    60. Layer文件或数据库读取到的地理数据
    61. FeatureLayer:矢量数据
    62. PasterLayer:栅格数据
    63. Element
    64. 往地图上添加图形
    65. 框架元素
    66. //修改其他设置
    67. IMapSurround pMapSurround = pMapSurrroundFrame.MapSurround;
    68. /* ILegend pLegend = pMapSurround as ILegend;
    69. pLegend.Title = "图例";*/
    70. //修改不同类型的Mapsurround的样式,要强制转化成该类型
    71. IScaleBar markerScalerBar = pMapSurround as IScaleBar;
    72. ///
    73. IEnvelope pEnvelop = new EnvelopeClass();
    74. ITextSymbol pTextSybol = new TextSymbolClass();
    75. MarkerNorthArrow markerNorthArrow = pMapSurround as IMarkerNorthArrow;
    76. //IStyleGalleryItem pStyleGalleryItem = SymbolUtilty.GetItemFromServerStyle("Scale Texts", "Absolute Scale");
    77. //弹出窗体的Symbolform
    78. //pMapSurrroundFrame.MapSurround = (IMapSurround)styleGalleryItem.Item;
    79. IElement pElement = pMapSurrroundFrame as IElement;
    80. // pElement.Geometry = pEnvelope;
    81. //pGraphicsContainer.AddElement(pElement,0); //地图元素的位置
    82. 添加地图元素到PageLayoutControl中
    83. IGraphicsContainer pGraphicsContainer = pPageLayout as IGraphicsContainer;
    84. IMap pMap = axPageLayout1.ActivieView.FocusMap;
    85. IFrameElement pFrameElement = pGraphicsContainer.FindFrame(pMap);
    86. IMapFrame pMapFrame = pFrameElement as IMapFrame;
    87. IMapSurrroundFrame pMapSurrroundFrame = MapSurrroundFrame CreateSurroundFrame(pID,null);
    88. pMapSurrroundFrame.MapSurrround = (IMapSurrround)styleGalleryItem.Item;
    89. IElement pElement = pMapSurrroundFrame as IElement;
    90. pElement.Geometry =
    91. // if (fileExtendName.ToUpper() == "JPG")
    92. //{
    93. // pExport = new ExportJPEGClass();
    94. //}
    95. //else if (fileExtendName.ToUpper() == "BMP")
    96. //{
    97. // pExport = new ExportBMPClass();
    98. //}
    99. private void button2_Click(object sender, EventArgs e)
    100. {
    101. //设置输出的缓冲图层
    102. SaveFileDialog saveDlg = new SaveFileDialog();
    103. saveDlg.CheckPathExists = true;
    104. saveDlg.Filter = "Shapefile (*.shp)|*.shp";
    105. saveDlg.OverwritePrompt = true;
    106. saveDlg.Title = "保存数据";
    107. saveDlg.RestoreDirectory = true;
    108. saveDlg.FileName = (string)comboBox1.SelectedItem + "_buffer.shp";
    109. DialogResult dr = saveDlg.ShowDialog();
    110. if (dr == DialogResult.OK)
    111. textBox2.Text = saveDlg.FileName;
    112. }
    113. //查询人口数量大于2500的区域
    114. string WhereClause = "pop > 2500";
    115. RgbColor pColor = setSelectionColor(153, 0, 0);
    116. SelectLayersFeatures(count, WhereClause, pColor);
    117. private void SelectLayersFeatures(int i, string WhereClause, RgbColor pColor)
    118. {//条件查询图层属性字段
    119. ILayer pLayer = axMapControl1.get_Layer(i);
    120. IFeatureLayer pFeatureLayer = (IFeatureLayer)pLayer;
    121. IFeatureSelection pFeatureSelection = pFeatureLayer as IFeatureSelection;
    122. if (pFeatureSelection != null)
    123. {
    124. IQueryFilter pQueryFilter = new QueryFilterClass();
    125. pQueryFilter.WhereClause = WhereClause;
    126. pFeatureSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
    127. }
    128. pFeatureSelection.SelectionColor = pColor;//将选择集添上颜色
    129. axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);//控件局部刷新
    130. }
    131. private RgbColor setSelectionColor(int red, int green, int blue)
    132. {//设置选择集颜色
    133. RgbColor pColor = new RgbColor();
    134. pColor.Red = red;
    135. pColor.Green = green;
    136. pColor.Blue = blue;
    137. return pColor;
    138. }

     部分节课报告要求

    1、程序启动的时候加载朝阳区的街道数据
    2、了解、分析POI数据:POI代表的是城市里的各种设施,如:商店、酒店、学校等,用之前实验中做的打开属性表功能,打开POI数据的属性属性,分析它的type属性(有3级type)
    3、在界面上提供菜单、或工具、或按钮用于加载POI数据,加载后不在mapcontrol中显示POI点数据,而是在程序界面上提供POI三级type的树状图(控件treeView)
    4、点击树状图中的每个节点时,在mapcontrol中显示具有相应属性值的POI数据,注意去除前一视图中的POI数据
    5、在树状图中点击鼠标右键时弹出菜单,菜单上具有城市基础设施空间分布分析的功能,这些功能是以街区为单位,统计每个街区内的各类设施的数量,根据这个数量设计专题图;此外,还可以计算出各街区内、各种基础设施统计数据的方差,用这些方差值做一个曲线图,看看哪种基础设施的方差最小(表示其分布最为均匀)


    以每一个街区为单位输出,全称2010或以FTD进行叠加查询
    叠加分析是将有关主题层组成的数据层面,进行叠加产生一个新数据层面的操作,其结果综合了原来 两层或多层要素所具有的属性,从已有的数据中提取空间隐含的信息。

    总体设计

    本次开发的系统将为用户提供一个简洁明了、易于操作的工作界面,使用户能够轻松便捷的获取到**市**区的基础设施空间分布的关系和地图数据,在原数据的基础上进行基本的操作、查询和分析。任何软件的最终受用群体是人这个自然体,所以不管是什么样的软件,必须要考虑用户在使用中的感受,无论是控件使用,提示信息措辞,还是颜色、窗口布局风格,遵循统一的标准,做到真正的一致。

     

     

     

     

     

     

     具体的代码和相关报告压缩放在

     

     

  • 相关阅读:
    数学 (一个正整数分解成多个连续正整数的和) + 整数每次减少一位加和
    Linux - Linux下Java安装路径查找;配置Java环境变量
    23.C++之STL(一)
    客户关系管理系统(CRM)开发的意义
    【Cherno的C++视频】Visual benchmarking in C++
    SpringCloud 05 Eureka集群环境配置和CAP
    微信小程序之console.log()使用
    2022建筑架子工(建筑特殊工种)考试练习题及在线模拟考试
    ARMv8函数传参中的bug!
    相机相关:相机模型与畸变模型
  • 原文地址:https://blog.csdn.net/xuxuan1997/article/details/126754323