ArcEngine实现空间分析

Posted 杨千羽

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ArcEngine实现空间分析相关的知识,希望对你有一定的参考价值。

<div class="page-title pad group">

		<ul class="meta-single group">
		<li class="category"><a href="https://www.giserdqy.com/arcengine/" rel="category tag">ArcEngine</a></li>
				</ul>
				<article class="post-26960 post type-post status-publish format-standard has-post-thumbnail hentry category-arcengine tag-arcengine">
			<div class="post-inner group">
				<p id="breadcrumbs"><span><span><a href="https://www.giserdqy.com/">首页</a> » <span><a href="https://www.giserdqy.com/arcengine/">ArcEngine</a> » <span class="breadcrumb_last" aria-current="page">ArcEngine实现空间分析</span></span></span></span></p>					<h1 class="post-title">ArcEngine实现空间分析</h1>
				
				<div class="bdsharebuttonbox bdshare-button-style0-24" data-bd-bind="1563003227441"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_mshare" data-cmd="mshare" title="分享到一键分享"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a><a href="#" class="bds_youdao" data-cmd="youdao" title="分享到有道云笔记"></a><a href="#" class="bds_twi" data-cmd="twi" title="分享到Twitter"></a><a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a><a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a><a href="#" class="bds_copy" data-cmd="copy" title="分享到复制网址"></a><a href="#" class="bds_print" data-cmd="print" title="分享到打印"></a></div>
				<p class="post-byline">by <a href="https://www.giserdqy.com/author/dqy/" title="由giser发布" rel="author">giser</a> · 2019-04-05</p>

				
				<div class="clear"></div>

				<div class="entry ">
					<div class="entry-inner">
						<div id="ez-toc-container" class="counter-hierarchy counter-decimal">

目录

1.熟悉 ITopologicalOperator 接口(用于空间拓扑运算)的使用 2.熟悉 IRelationalOperator 接口(用于空间关联运算)的使用 3.熟悉 IProximityOperator 接口(用于空间距离运算)的使用

●·● 目录:

A1 ………… ITopologicalOperator5 接口

A2 ………… IRelationalOperator 接口

A3 ………… IPoint 接口
A4 ………… ICurve3 接口
A5 ………… ISegment 接口
A6 ………… ICircularArc 接口

———————————————————————————————————

            ╔════════╗
╠════╣    第A1个    ╠══════════════════════════════════════════════════╣
            ╚════════╝

●·● ITopologicalOperator5
接口

1. Provides additional information on non-simple geometries.【拓扑操作】

  Members

  Description
Boundary
返回值:IGeometry
The boundary of this geometry. A polygon’s boundary is a polyline. A polyline’s boundary is a multipoint. A point or multipoint’s boundary is an empty point or multipoint.
Buffer
(double distance)
返回值:IGeometry
Constructs a polygon that is the locus of points at a distance less than or equal to a specified distance from this geometry.
通过给定距离,得到操作图形的缓冲区,返回得到缓冲区几何图形!
但是这里面的距离很是蹊跷,同时实验发现,我写入 0.01 的时候,大约表示 1km,所以大约是 1:100 000 的关系!
Clip
(IEnvelope clipperEnvelope)
Constructs the intersection of this geometry and the specified envelope.
返回矩形部分的要素,直接作用在要素上面!
ClipDenseConstructs the intersection of this geometry and the specified envelope; densifies lines in output contributed by the clipping envelope.
ClipExConstructs the intersection of this geometry and the specified envelope.
ClipToDomainClips the geometry to the domain of the spatial reference. Useful for ensuring that buffers can be fit within the spatial domain of the feature class to which they are being added.
ConstructUnionDefines this geometry to be the union of the inputs. More efficient for unioning multiple geometries than calling Union repeatedly.
ConvexHullConstructs the convex hull of this geometry.
CutSplits this geometry into a part left of the cutting polyline, and a part right of it.
Cut2Divides a geometry into multiple parts
DifferenceConstructs the geometry containing points from this geometry but not the other geometry.
GeoNormalizeExShifts longitudes, if need be, into a continuous range of 360 degrees.
IntersectConstructs the geometry that is the set-theoretic intersection of the input geometries. Use different resultDimension values to generate results of different dimensions.
IntersectMultidimensionConstructs the set-theoretic intersection of the inputs. The results are returned in a geometry bag with one element per result dimension.
IsKnownSimpleIndicates whether this geometry is known (or assumed) to be topologically correct.
IsKnownSimpleIndicates whether this geometry is known (or assumed) to be topologically correct.
IsSimpleIndicates whether this geometry is known (or assumed) to be topologically correct, after explicitly determining this if the geometry is not already known (or assumed) to be simple.
IsSimpleExDetermines why a geometry is not simple. Currently only implemented for polygons.
QueryClippedRedefines clippedGeometry to be the intersection of this geometry and the clipping envelope.
QueryClippedDenseRedefines clippedGeometry to be the intersection of this geometry and the clipping envelope; densifies lines in the output contributed by the clipping envelope.
SimplifyMakes this geometry topologically correct.
SymmetricDifferenceConstructs the geometry that contains points from either but not both input geometries.
UnionConstructs the geometry that is the set-theoretic union of the input geometries.

  CoClasses that implement ITopologicalOperator

CoClasses and ClassesDescription
GeoEllipse
(esriDefenseSolutions)
Its a spheroidal ellipse.
GeometryBagAn ordered collection of objects that support the IGeometry interface.
GeoPolygon
(esriDefenseSolutions)
Its a spheroidal polygon.
GeoPolyline
(esriDefenseSolutions)
This is a spheroidal polyline.
MultiPatchA collection of surface patches.
MultipointAn ordered collection of points; optionally has measure, height and ID attributes.
PointA two dimensional point, optionally with measure, height, and ID attributes.
PolygonA collection of rings ordered by their containment relationship; optionally has measure, height and ID attributes.
PolylineAn ordered collection of paths; optionally has measure, height and ID attributes.

※ | ※ → 公共代码部分:

//公共变量!~

   
  1. IMap pMap;
  2. IActiveView pActiveView;
  3. IEnvelope pEnv;
  4. ISelectionEnvironment pSelectionEnv;
  5. IEnumFeature pEnumFeature;
  6. IGraphicsContainer pGraphicsContainer;
  7. IFeature pFeature;
  8. IGeometry pGeometry;
  9. IEnvelope pEnvClip;
  10. IPolyline pLineCut;
  11. IPolygon pFirstPolygon;

//鼠标点击事件!~

   
  1. private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
  2. axMapControl1.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
  3. if (isClip) //此时要拉Clip框
  4. pEnvClip = axMapControl1.TrackRectangle();
  5. isClip = false;
  6. else if (isCut)
  7. pLineCut = axMapControl1.TrackLine() as IPolyline;
  8. isCut = false;
  9. else if (isFirstIn)
  10. pMap = axMapControl1.Map;
  11. pActiveView = pMap as IActiveView;
  12. pEnv = axMapControl1.TrackRectangle();
  13.  
  14. pSelectionEnv = new SelectionEnvironment();
  15. pSelectionEnv.DefaultColor = GetColor(0, 255, 0);
  16. pMap.SelectByShape(pEnv, pSelectionEnv, false);
  17. pActiveView.Refresh();
  18. pEnumFeature = axMapControl1.Map.FeatureSelection as IEnumFeature;
  19. else
  20. pMap = axMapControl1.Map;
  21. pActiveView = pMap as IActiveView;
  22. pEnv = axMapControl1.TrackRectangle();
  23.  
  24. pSelectionEnv = new SelectionEnvironment();
  25. pSelectionEnv.DefaultColor = GetColor(255, 0, 0);
  26. pMap.SelectByShape(pEnv, pSelectionEnv, false);
  27. pActiveView.Refresh();
  28. pEnumFeature = axMapControl1.Map.FeatureSelection as IEnumFeature;

//RGB颜色!~

   
  1. private IRgbColor GetColor(int r, int g, int b)
  2. IRgbColor pColor = new RgbColor();
  3. pColor.Red = r;
  4. pColor.Green = g;
  5. pColor.Blue = b;
  6. return pColor;

 

※ | ※ → Buffer:

   
  1. private void button1_Click(object sender, EventArgs e)
  2. while (true)
  3. pGraphicsContainer = pMap as IGraphicsContainer; //定义容器
  4. pFeature = pEnumFeature.Next(); //遍历要素
  5. if (pFeature == null) //若不存在要素,则推出循环
  6. break;
  7. pGeometry = pFeature.Shape; //获取要素的Geometry
  8. ITopologicalOperator pTopoOperator = pGeometry as ITopologicalOperator; //QI到拓扑操作
  9. IGeometry pBufferGeo = pTopoOperator.Buffer(2); //缓冲区分析
  10.  
  11. IElement pElement = new PolygonElement();
  12. pElement.Geometry = pBufferGeo; //获取得到的缓冲区
  13.  
  14. pGraphicsContainer.AddElement(pElement, 0); //显示缓冲区
  15. pActiveView.Refresh();

 

※ | ※ → Boundary:

   
  1. private void button2_Click(object sender, EventArgs e)
  2. while (true)
  3. pGraphicsContainer = pMap as IGraphicsContainer; //定义容器
  4. pFeature = pEnumFeature.Next(); //遍历要素
  5. if (pFeature == null) //若不存在要素,则推出循环
  6. break;
  7. pGeometry = pFeature.Shape; //获取要素的Geometry
  8. ITopologicalOperator pTopoOperator = pGeometry as ITopologicalOperator; //QI到拓扑操作
  9. IGeometry pBoundary = pTopoOperator.Boundary; //获取边界
  10.  
  11. ILineElement pLineEle = new LineElementClass();
  12. ISimpleLineSymbol pSLS = new SimpleLineSymbol();
  13. IRgbColor pColor = GetColor(0, 255, 0);
  14. pSLS.Color = pColor;
  15. pSLS.Width = 5;
  16. pLineEle.Symbol = pSLS;
  17.  
  18. IElement pElement = pLineEle as IElement;
  19. pElement.Geometry = pBoundary;
  20.  
  21. pGraphicsContainer.AddElement(pElement, 0); //显示边界
  22. pActiveView.Refresh();

 

※ | ※ → Clip:

   
  1. bool isClip = false;
  2. private void button3_Click(object sender, EventArgs e)
  3. isClip = true;
  4.  
  5. private void button4_Click(object sender, EventArgs e)
  6. while (true)
  7. pGraphicsContainer = pMap as IGraphicsContainer; //定义容器
  8. pFeature = pEnumFeature.Next(); //遍历要素
  9. if (pFeature == null) //若不存在要素,则推出循环
  10. break;
  11. pGeometry = pFeature.Shape; //获取要素的Geometry
  12. ITopologicalOperator pTopoOperator = pGeometry as ITopologicalOperator; //QI到拓扑操作
  13. pTopoOperator.Clip(pEnvClip);
  14.  
  15. IElement pElement = new PolygonElement();
  16. pElement.Geometry = pGeometry; //获取得到的缓冲区
  17.  
  18. pGraphicsContainer.AddElement(pElement, 0); //显示缓冲区
  19. pActiveView.Refresh();

 

※ | ※ → ConvexHull:

   
  1. private void button5_Click(object sender, EventArgs e)
  2. while (true)
  3. pGraphicsContainer = pMap as IGraphicsContainer; //定义容器
  4. pFeature = pEnumFeature.Next(); //遍历要素
  5. if (pFeature == null) //若不存在要素,则推出循环
  6. break;
  7. pGeometry = pFeature.Shape; //获取要素的Geometry
  8. ITopologicalOperator pTopoOperator = pGeometry as ITopologicalOperator; //QI到拓扑操作
  9. IGeometry pBufferGeo = pTopoOperator.ConvexHull();
  10.  
  11. IElement pElement = new PolygonElement();
  12. pElement.Geometry = pBufferGeo; //获取得到的缓冲区
  13.  
  14. pGraphicsContainer.AddElement(pElement, 0); //显示缓冲区
  15. pActiveView.Refresh();

 

※ | ※ → Cut:

   
  1. bool isCut = false;
  2.  
  3. private void button6_Click(object sender, EventArgs e)
  4. isCut = true;
  5.  
  6. private void button7_Click(object sender, EventArgs e)
  7. while (true)
  8. pGraphicsContainer = pMap as IGraphicsContainer; //定义容器
  9. pFeature = pEnumFeature.Next(); //遍历要素
  10. if (pFeature == null) //若不存在要素,则推出循环
  11. break;
  12. pGeometry = pFeature.Shape; //获取要素的Geometry
  13. ITopologicalOperator pTopoOperator = pGeometry as ITopologicalOperator; //QI到拓扑操作ry
  14. IGeometry pGeoRight = new PolygonClass();
  15. IGeometry pGeoLeft = new PolygonClass();
  16. pTopoOperator.Cut(pLineCut, out pGeoLeft, out pGeoRight);
  17.  
  18. IElement pElement = new PolygonElement();
  19.  
  20. IFillShapeElement pFillEle = pElement as IFillShapeElement;
  21. ISimpleFillSymbol pSFS = new SimpleFillSymbol();
  22. pSFS.Color = GetColor(255, 255, 0);
  23. pFillEle.Symbol = pSFS;
  24.  
  25. pElement.Geometry = pGeoLeft; //获取得到的缓冲区
  26. pGraphicsContainer.AddElement(pElement, 0); //显示缓冲区
  27.  
  28. pSFS = new SimpleFillSymbol();
  29. pSFS.Color = GetColor(255, 0, 以上是关于ArcEngine实现空间分析的主要内容,如果未能解决你的问题,请参考以下文章

    ArcEngine实现空间分析

    ArcEngine空间分析

    ArcEngine查询添加删除要数的方法

    arcengine featureclass里怎么添加feature

    ArcEngine——获取要素几何(非游标方式)

    arcEngine开发之IMapControl接口