版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、【051】 ArcEngine实现空间分析 1熟悉ITopologicalOperator接口(用于空间拓扑运算)的使用 2熟悉IRelationalOperator接口(用于空间关联运算)的使用 3熟悉IProximityOperator接口(用于空间距离运算)的使用 录:A1ITopologicalOperator5 接口公共方法:Buffer 方法:Boundary 方法Clip方法ConvexHull 方法Cut方法Union方法:Intersect 方法Difference 方法A2IRelationalOperator 接口公共方法Contains 方法Overlaps 方法A3I
2、Point接口A4ICurve3接口A5ISegment接口A6ICircularArc 接口写在前面:使用空间分析的时候,会提示这样的错误异常来自HRESULT:0 x80040215,其原 因就是:在使用ITopologicalOperator求交集等操作的时候,有时会出现“ HRESULT: 0 x8 004 0215”这个异常,原来是空间参考不一样所致。因此只要SpatialReference属性设为同一空间参考就不会出现“ HRESULT: 0 x8004 0215”异常。所以在进行空间分析之前,要保证所建立的shapefile文件具有相同的 SpatialRefere nee!II
3、第A1个II TopologicalOperator5 接口:1. Provides additional information on non-simple geometries.【拓扌卜操作】MembersDescriptionBoundary返回值:IGeometryThe bounda ry of this geomet ry. A polygons bounda ry is a polyline A polylines bounda ry is a multipoint. A point or multipoints bounda ry is an empty point or mu
4、ltipoint.Buffer(double distance) 返回值:IGeometryConst ructs a polygon that is the locus of points at a distance less than or equal to a specified distance from this geomet ry.通过给定距离,得到操作图形的缓冲区,返回得到缓冲区几何图形! 但是这里面的距离很是蹊跷,同时实验发现,我写入0.01的时候,大约表 示1km,所以大约是1:100 000的关系!JClip(IEnvelope clippeEnvelope)Const r
5、ucts the intesection of this geomet ry and the specified envelope.返回矩形部分的要素,直接作用在要素上面!ClipDenseConst ructs the intesection of this geomet ry and the specified envelope; densifies lines in output contributed by the clipping envelope.ClipExConst ructs the intesection of this geomet ry and the specifie
6、d envelope.ClipToDomainClips the geomet ry to the domain of the spatial refer ence. Useful for ens ur ing that buffe rs can be fit within the spatial domain of the feat ure class to which they are being added.ConstructUnionDefines this geomet ry to be the union of the inputs. More efficient for unio
7、ning multiple geomet ries than calling Union r epeatedly.ConvexHullConst ructs the convex hull of this geomet ry.CutSplits this geomet ry into a part left of the cutting polyline, and a part right of it.JCut2Divides a geomet ry into multiple partsJDifferenceConst ructs the geometry containing points
8、 from this geomet ry but not the othe r geomet ry.JGeoNormalizeExShifts longitudes, if need be, into a continuous r ange of 360 deg rees.JIntersectConst ructs the geometry that is the set-the or etic intesection of the input geomet ries. Use diffe rent r esultDimension values to gene rate r esults o
9、f diffe rent dimensions.IntersectMultidimensionConst ructs the set-the or etic intesection of the inputs. The r esults are retur ned in a geomet ry bag with one element per r esult dimension.IsKnownSimpleIndicates whethe r this geomet ry is known (or assumed) to be topologically corr ect.IsKnownSimp
10、leIndicates whethe r this geomet ry is known (or assumed) to be topologically corr ect.IsSimpleIndicates whethe r this geomet ry is known (or assumed) to be topologically corr ect, after explicitly dete rmining this if the geomet ry is not al ready known (or assumed) to be simple.IsSimpleExDete rmin
11、es why a geomet ry is not simple. Curr ently only implemented for polygons.QueryClippedRedefines clippedGeometry to be the intesection of this geometry and the clipping envelope.QueryClippedDenseRedefines clippedGeometry to be the intesection of this geometry and the clipping envelope; densifies lin
12、es in the output cont ributed by the clipping envelope.SimplifyMakes this geomet ry topologically corr ect.SymmetricDifferenceConst ructs the geometry that contains points from eithe r but not both input geomet ries.UnionConst ructs the geometry that is the set-the or etic union of the inpu geomet r
13、ies.CoClasses that implement ITopologicalOperatorCoClasses and ClassesDescriptionGeoEllipse (esriDefenseSolutions)Its a sphe ro idal ellipse.GeometryBagAn ordered collection of objects that supp ort the IGeomet ry inte rfaceGeoPolygonIts a sphe ro idal polygon.(esriDefenseSolutions)GeoPolyline (esri
14、DefenseSolutions)This is a sphe ro idal polyline.MultiPatchA collection of sur face patches.MultipointAn ordered collection of points; optionally has meas ure, height and ID att ributes.PointA two dimensional point, optionally with meas ure, height, and ID att ributes.PolygonA collection of rings or
15、dered by thei r containment r elationship; optionally has meas ure, height and ID att ributes.PolylineAn ordered collection of paths; optionally has meas ure, height and ID att ributes.探I公共代码部分:公共变量! IMap pMap;IActiveView pActiveView;IEnvelope pEnv;ISelectionEnvironment pSelectionEnv; IEnumFeature p
16、EnumFeature;IGraphicsContainer pGraphicsContainer; IFeature pFeature;IGeometry pGeometry;IEnvelope pEnvClip;IPolyline pLineCut;IPolygon pFirstPolygon;鼠标点击事件!private void axMapControl1_OnMouseDown(object sender,IMapControlEvents2_OnMouseDownEvent e)axMapControl1.MousePointer =esriControlsMousePointer
17、.esriPointerCrosshair;if (isClip) /此时要拉 Clip 框pEnvClip = axMapControl1.TrackRectangle(); isClip =false;else if (isCut)pLineCut = axMapControl1.TrackLine() as IPolyline; isCut =false;else if (isFirstIn)pMap = axMapControl1.Map;pActiveView = pMapas IActiveView;pEnv = axMapControl1.TrackRectangle();pSe
18、lectionEnv =new SelectionEnvironment();IEnumFeature;IEnumFeature;pSelectionEnv.Defaultcolor = GetColor0, 255, 0 ); pMap.SelectByShape(pEnv, pSelectionEnv,false); pActiveView.Refresh();IEnumFeature;IEnumFeature;pEnumFeature = axMapControl1.Map.FeatureSelectionas elsepMap = axMapControl1.Map;pActiveVi
19、ew = pMapas IActiveView;pEnv = axMapControl1.TrackRectangle();pSelectionEnv =new SelectionEnvironment();pSelectionEnv.DefaultColor = GetColor255, 0, 0); pMap.SelectByShape(pEnv, pSelectionEnv,false); pActiveView.Refresh();pEnumFeature = axMapControl1.Map.FeatureSelectionas /RGB 颜色! private IRgbColor
20、 GetColor(int r, int g, int b) IRgbColor pColor = new RgbColor(); pColor.Red = r;pColor.Green = g; pColor.Blue = b;return pColor;探 | 探 f Buffer:private void button1_Click(object sender, EventArgs e)while (true)pGraphicsContainer = pMapas IGraphicsContainer;/定义容器pFeature = pEnumFeature.Next();/遍历要素if
21、 (pFeature = null)/若不存在要素,则推出循环break;pGeometry = pFeature.Shape;/获取要素的 GeometryITopologicalOperator pTopoOperator = pGeometras ITopologicalOperator;/QI到拓扑操作IGeometry pBufferGeo = pTopoOperator.Buffer2();/缓冲区分析IElement pElement =new PolygonElement();pElement.Geometry = pBufferGeo;/获取得到的缓冲区pGraphicsCo
22、ntainer.AddElement(pElement,0); /显示缓冲区 pActiveView.Refresh();探 | 探Boundary:private void button2_Click(object sender, EventArgs e)while (true)pGraphicsContainer = pMapas IGraphicsContainer;/定义容器pFeature = pEnumFeature.Next();/遍历要素if (pFeature = null)/若不存在要素,则推出循环break;pGeometry = pFeature.Shape;/获取要素
23、的 GeometryITopologicalOperator pTopoOperator = pGeometras ITopologicalOperator;/QI到拓扑操作IGeometry pBoundary = pTopoOperator.Boundary; /获取边界ILineElement pLineEle =new LineElementClass();ISimpleLineSymbol pSLS =new SimpleLineSymbol(); IRgbColor pColor = GetColorO, 255, 0);pSLS.Color = pColor; pSLS.Widt
24、h =5;pLineEle.Symbol = pSLS;IElement pElement = pLineEleas IElement; pElement.Geometry = pBoundary;pGraphicsContainer AddElement(pElement,0 ); /显示边界 pActiveView.Refresh();探 | 探 f Clip:bool isClip = false;private void button3_Click(object sender, EventArgs e) isClip = true;while (true)pGraphicsContai
25、ner = pMapas IGraphicsContainer;/定义容器pFeature = pEnumFeature.Next();/遍历要素if (pFeature = null)/若不存在要素,则推出循环break;pGeometry = pFeature.Shape;/获取要素的 GeometryITopologicalOperator pTopoOperator = pGeometras ITopologicalOperator;/QI到拓扑操作pTopoOperator.Clip(pEnvClip);IElement pElement =new PolygonElement();
26、pElement.Geometry = pGeometry;/获取得到的缓冲区pGraphicsContainer.AddElement(pElement,0 ); /显示缓冲区 pActiveView.Refresh();| 探ConvexHull:while (true)pGraphicsContainer = pMapas IGraphicsContainer;/定义容器pFeature = pEnumFeature.Next();/遍历要素if (pFeature = null)/若不存在要素,则推出循环break;pGeometry = pFeature.Shape;/获取要素的 G
27、eometryITopologicalOperator pTopoOperator = pGeometras ITopologicalOperator;/QI到拓扑操作IGeometry pBufferGeo = pTopoOperator.ConvexHull();IElement pElement =new PolygonElement();pElement.Geometry = pBufferGeo;/获取得到的缓冲区pGraphicsContainer.AddElement(pElement,0 ); /显示缓冲区 pActiveView.Refresh();探|Cut:bool is
28、Cut = false;private void button6_Click(object sender, EventArgs e)isCut = true;private void button7_Click(object sender, EventArgs e)while (true)pGraphicsContainer = pMapas IGraphicsContainer;/定义容器pFeature = pEnumFeature.Next();/遍历要素if (pFeature = null)/若不存在要素,则推出循环break;pGeometry = pFeature.Shape;
29、/获取要素的 GeometryITopologicalOperator pTopoOperator = pGeometras ITopologicalOperator;/QI到拓扑操作ryIGeometry pGeoRight =new PolygonClass();IGeometry pGeoLeft =new PolygonClass();pTopoOperator Cut(pLineCut,out pGeoLeft, out pGeoRight);IElement pElement =new PolygonElement();IFillShapeElement pFillEle = pE
30、lementas IFillShapeElement;ISimpleFillSymbol pSFS =new SimpleFillSymbol();pSFS.Color = GetColor255, 255, 0);pFillEle.Symbol = pSFS;pElement.Geometry = pGeoLeft;/获取得到的缓冲区pGraphicsContainer.AddElement(pElement, 0 ); /显示缓冲区pSFS =new SimpleFillSymbol();pSFS.Color = GetColor255, 0, 255);pFillEle.Symbol =
31、 pSFS;pElement =new PolygonElement();pElement.Geometry = pGeoRight;/获取得到的缓冲区pGraphicsContainer.AddElement(pElement, 0 ); /显示缓冲区 pActiveView.Refresh();探 | 探 f Union:private void button8_Click(object sender, EventArgs e)IGeometry pUnionGeo = new PolygonClass();pGraphicsContainer = pMap as IGraphicsCon
32、tainer;/定义容器while (true)pFeature = pEnumFeature.Next();/遍历要素if (pFeature = null)/若不存在要素,则推出循环break;pGeometry = pFeature.Shape;/获取要素的 GeometryITopologicalOperator pTopoOperator = pUnionGeas ITopologicalOperator;/QI到拓扑操作rypUnionGeo = pTopoOperator.Union(pGeometry);IElement pElement = new PolygonElemen
33、t();IFillShapeElement pFillEle = pElement as IFillShapeElement;ISimpleFillSymbol pSFS = new SimpleFillSymbol();pSFS.Color = GetColor 255, 255, 0);pFillEle.Symbol = pSFS;pElement .Geometry = pUnionGeo; /获取得到的缓冲区 pGraphicsContainer AddElement(pElement, 0 ); /显示缓冲区 pActiveView.Refresh();探 | Intersect:b
34、ool isFirstIn = false;private void button10_Click(object sender, EventArgs e)isFirstIn = true;private void button11_Click(object sender, EventArgs e)isFirstIn = false;pFirstPolygon = new PolygonClass();while (true)pFeature = pEnumFeature.Next();if (pFeature = null)break;pGeometry = pFeature.Shape;IT
35、opologicalOperator pTopoOperator = pFirstPolygon as ITopologicalOperator;pFirstPolygon = pTopoOperator.Union(pGeometry) as IPolygon; private void button12_Click(object sender, EventArgs e)IGeometry pIntersectGeo = new PolygonClass();IGeometry pSecondPolygon = new PolygonClass();pGraphicsContainer =
36、pMap as IGraphicsContainer;while (true)pFeature = pEnumFeature.Next();if (pFeature = null)break;pGeometry = pFeature.Shape;ITopologicalOperator pTopoOperator = pSecondPolygonas ITopologicalOperator;pSecondPolygon = pTopoOperator Union(pGeometry) as IPolygon;ITopologicalOperator pTopo = pSecondPolygo
37、n as ITopologicalOperator; pIntersectGeo = pTopo.Intersect(pFirstPolygon, esriGeometryDimension.esriGeometry2Dimension) as IPolygon;IElement pElement = new PolygonElementClass(); pElement.Geometry = pIntersectGeo;pGraphicsContainer.AddElement(pElement, 0);IFeatureLayer pFeatureLayer = pMap.get_Layer
38、 0) as IFeatureLayer; pFeatureLayer Visible = false;pFeatureLayer = pMap.get_Layer1) as IFeatureLayer;pFeatureLayer Visible = false; pActiveView.Refresh();探|探f Difference:(需要前面两部分)private void button13_Click(object sender, EventArgs e)IGeometry pIntersectGeo = new PolygonClass();IGeometry pSecondPol
39、ygon = new PolygonClass(); pGraphicsContainer = pMap as IGraphicsContainer;while (true)pFeature = pEnumFeature.Next();if (pFeature = null)break;pGeometry = pFeature.Shape;ITopologicalOperator pTopoOperator = pSecondPolygonas ITopologicalOperator;pSecondPolygon = pTopoOperator Union(pGeometry) as IPo
40、lygon;ITopologicalOperator pTopo = pSecondPolygon as ITopologicalOperator; pIntersectGeo = pTopo.Difference(pFirstPolygon) as IPolygon;IElement pElement = new PolygonElementClass(); pElement.Geometry = pIntersectGeo;pGraphicsContainer.AddElement(pElement, 0);IFeatureLayer pFeatureLayer = pMap get_La
41、yer 0) as IFeatureLayer; pFeatureLayer Visible = false;pFeatureLayer = pMap.get_Layer1) as IFeatureLayer;pFeatureLayer Visible = false;pActiveView.Refresh();iiiII第A2个II elationalOperator 接口:1. Provides access to members that determine if a certain spatial relatio nship exists betwee n two geometries
42、.MembersDescriptionContainsIndicates if this geomet ry contains the othe r geomet ry. 前者是否包含后者!CrossesIndicates if the two geomet ries inte rsect in a geomet ry of lesse r dimension.DisjointIndicates if the two geomet ries sha re no points in common. Negat this r esult to compute the Inte rsect r el
43、ation.EqualsIndicates if the two geomet ries are of the same type and define th same set of points in the plane.OverlapsIndicates if the intesection of the two geomet ries has the same dimension as one of the input geomet ries.前者和后者是否有重叠!不包括包含关系!RelationIndicates if the defined r elationship exists.
44、TouchesIndicates if the boundaries of the geometries intersect.WithinIndicates if this geomet ry is contained (is within) anothe r geomet ry.前者是否在后者内部!CoClasses that implement IRelationalOperatorCoClasses and ClassesDescriptionEnvelopeA r ectangle with sides par allel to a coor dinate system definin
45、g the extent of anothe r geomet ry; optionally has min and max meas ure, height and ID att ributes.GeometryBagAn ordered collection of objects that supp ort the IGeomet ry inte rfaceMultiPatchA collection of sur face patches.MultipointAn ordered collection of points; optionally has meas ure, height
46、and ID att ributes.PointA two dimensional point, optionally with meas ure, height, and ID att ributes.PolygonA collection of rings ordered by thei r containment r elationship; optionally has meas ure, height and ID att ributes.PolylineAn ordered collection of paths; optionally has meas ure, height a
47、nd ID att ributes.探I公共代码部分:IMap pMap;IActiveView pActiveView;IEnvelope pEnv;ISelectionEnvironment pSelectionEnv;IEnumFeature pEnumFeature;IFeature pFeature;IGeometry pGeometry;IGeometry pBasicGeo;private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_0nMouseDownEvent e)axMapControl
48、1.MousePointer = esriControlsMousePointer.esriPointerCrosshair;pMap = axMapControl1.Map;pActiveView = pMap as IActiveView;pEnv = axMapControl1.TrackRectangle(); pSelectionEnv = new SelectionEnvironment(); pSelectionEnv.Defaultcolor = GetColor 255, 0, 0);pMap.SelectByShape(pEnv, pSelectionEnv, false); pActiveView.Refresh();pEnumFeature = pMap.FeatureSelection as IEnumFeature; private IRgbColor GetColor(int r, int g, int b) IRgbColor pColor = new RgbColor(); pColor.Red = r;pColor.Green = g;pColor.Blue = b;return pColor;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 睫毛膏式染发笔市场洞察报告
- 游泳池充气游戏器具市场发展预测和趋势分析
- 家用电动食品处理机市场发展现状调查及供需格局分析预测报告
- 带兜帽的风雪大衣产品入市调查研究报告
- 煤气炉家用取暖器产业深度调研及未来发展现状趋势
- 纸制桌旗产业深度调研及未来发展现状趋势
- 玩具风铃市场发展现状调查及供需格局分析预测报告
- 渡船产品入市调查研究报告
- 档案卡产业深度调研及未来发展现状趋势
- 娱乐用浮板市场洞察报告
- 计算机网络技术大学生职业生涯规划
- 走近湖湘红色人物智慧树知到期末考试答案2024年
- 兽医检验习题(附答案)
- 中考英语选择题120题(含答案)
- 机关团体企事业单位消防安全管理规定课件
- 苏教版四年级上册数学应用题100题及答案
- 护理生涯发展展示
- 中国电气装备集团2024年招聘考试试题
- 与时代同向与祖国同行
- 混凝土组织供应运输售后服务方案
- 四级营养师模拟及答案
评论
0/150
提交评论