ArcGIS Engine空间剖析之缓冲区剖析的完成
2019-11-18杂谈搜奇网43°c
A+ A-缓冲剖析(BufferAnalysis)的效果是一个面状要素——即缓冲要素,点状要素、线状要素和面状要素,被缓冲剖析功用处理过以后,它们的四周发生一个缓冲地区,该地区即新发生的面状要素。
在缓冲方向上,点状要素和线状要素只能举行向外缓冲,面状要素能够双向缓冲——向外缓冲和向内缓冲。
在ArcGIS Engine中,缓冲剖析由ITopologicalOperator.Buffer(double Distance)来完成,函数的返回值为IGeometry(表5-12)。个中,输入的参数为正时向外缓冲,为负时向内缓冲。
缓冲剖析完成的基本思路为:
1、设置缓冲间隔
2、挪用ITopologicalOperator.Buffer()要领生成缓冲区
3、向axMapControl中增加缓冲区。
// // 择要: // Constructs a polygon that is the locus of points at a distance less than or equal // to a specified distance from this geometry. // 组织一个多边形,该多边形是间隔此多少体小于或即是指定间隔的点的轨迹。 IGeometry Buffer(double distance);
(1)Buffer要领的参数
Bulfer要领仅照顾了唯一的一个参数:distance,它用以设置缓冲的间隔。输入的数字为正时向外缓冲;为负时向内缓冲(仅面状对象)。
(2)Buffer功用的基本思路
Buffer要领并没有发生新的要素类(Feature Class),由于Buffer要领的返回值为lGeometry,仅为要素的多少外形,不照顾任何要素属性特性。
所以说,在ArcGIS Engine中,Buffer要领并不能直接发生一个缓冲效果的要素对象。
显现了触发Bufer按钮事宜,如图所示:
缓冲区剖析函数:BufferArea(double BuffDistance)
/// <summary> /// 缓冲区剖析函数 /// </summary> /// <param name="BuffDistance">缓冲区间隔</param> private void BufferArea(double BuffDistance) { //以主地图为缓冲区增加对象 IGraphicsContainer graphicsContainer = axMapControl1.Map as IGraphicsContainer; //删除之前存留的一切元素 graphicsContainer.DeleteAllElements(); //选中索引值为0的图层 ILayer layer = axMapControl1.get_Layer(0); //此轮回用于查找图层名为LayerName的图层索引 /* ILayer layer = null; for (int i = 0; i < axMapControl1.LayerCount; i++) { if (axMapControl1.get_Layer(i).Name.Equals("Layer-Name")) { layer = axMapControl1.get_Layer(i); break; } } */ //将图层名为LayerName的图层强转成要素挑选集 IFeatureSelection pFtSel = (IFeatureLayer)layer as IFeatureSelection; //将图层名为LayerName的图层中的一切要素到场挑选集 pFtSel.SelectFeatures(null, esriSelectionResultEnum.esriSelectionResultNew, false); ICursor pCursor; //取得遍历挑选集合一切要素的游标 pFtSel.SelectionSet.Search(null, false, out pCursor); IFeatureCursor pFtCursor = pCursor as IFeatureCursor; IFeature pFt = pFtCursor.NextFeature(); //遍历一切挑选集合的一切要素, 逐一要素地建立缓冲区 while (pFt != null) { //将要素的多少对象(pFt.Shape)强转成ITopologicalOperator //pFt.Shape即为建立缓冲区的操纵对象 ITopologicalOperator topologicalOperator = pFt.Shape as ITopologicalOperator; //注重: BuffDIstance输入为正时向外缓冲, 为负时向内缓冲 IPolygon polygon = topologicalOperator.Buffer(BuffDistance) as IPolygon; //实例化要素以装载缓冲区 IElement element = new PolygonElement(); //将多少要素赋值为多边形 element.Geometry = polygon; //逐一显现 graphicsContainer.AddElement(element, 0); //指向下一个 pFt = pFtCursor.NextFeature(); } //这里消灭挑选集, 以避免高亮显现的要素与缓冲效果互相殽杂 pFtSel.Clear(); //革新axMapControl1 axMapControl1.Refresh(); }
中心缓冲剖析函数总结:
感谢寓目!本人初学GIS二次开发,如果有不对的处所,请多多见谅!
未定义标签