AE学习

博主说:以下内容来自ESRI论坛,只是收集资料时所编,能否正常运行,待博主试验过后再做公布!!

 

ae中缓冲区分析后用叠加分析比较好的思路:

 

实现思路分两步,首先要根据线做Buffer,生成一个多边形。
用  ITopologicalOperator. Buffer (distance ) ,得到一个Geometry
然后使用这个Geometry 做为条件,在需要分析的层进行空间搜索。空间搜索条件可以设为相交,
用到 ISpatialFilter接口和 IFeatureClass.Select或Search方法
假如分析结果涉及搜索到图形的面积长度,还要将查询结果特征与查询条件做求交运算。
会用到ITopologicalOperator. Intersect方法

 

 

实现缓冲区的代码:

private void button1_Click(object sender, EventArgs e)
        {
            if(buffertext.Text=="")
            {
                MessageBox.Show("请输入缓冲距离");
            }
            double distance = Convert.ToDouble(buffertext.Text);
            object missing = null;
            ITopologicalOperator pTopOperator;
            IFeature pFeature;
            IGeometry pGeometry;
            IPolygon pPolygon;
            IEnumFeature pEnumFeature;
            pEnumFeature = (IEnumFeature)    mainform.axMapControl1.Map.FeatureSelection;
            pEnumFeature.Reset();
            pFeature = pEnumFeature.Next();
            while (pFeature != null)
            {
                pGeometry = pFeature.Shape;
                pTopOperator = (ITopologicalOperator)pGeometry;
                pPolygon = pTopOperator.Buffer(distance) as IPolygon;
                mainform.axMapControl1.DrawShape(pPolygon, ref missing);
                pFeature = pEnumFeature.Next();
            }
        }

AE+c#实现缓冲区分析源码:

根据需要,可以设置pCursor实现对不同要素的缓冲区分析,

            IMap pMap = axMapControl1.Map;
            IGraphicsContainer pGeos = pMap as IGraphicsContainer;
            IFeatureLayer pFeatureLayer1 = pMap.get_Layer(0) as IFeatureLayer;
            IFeatureClass pClass1 = pFeatureLayer1.FeatureClass;

            IFeatureCursor pCursor1 = pClass1.Search(null, false);//整个图层

            IFeatureCursorBuffer pFeatureCursorBuffer = new FeatureCursorBufferClass();
            pFeatureCursorBuffer.PolygonBufferType = esriBufferType.esriBufferOutsideIncludeInside;
            pFeatureCursorBuffer.Dissolve = true ;
            pFeatureCursorBuffer.FeatureCursor = pCursor1;
            pFeatureCursorBuffer.ValueDistance = 100;
            pFeatureCursorBuffer.set_Units(pMap.MapUnits, esriUnits.esriMeters);

            #region 缓冲分析参数
            IBufferProcessingParameter bufferProcessingParameter = pFeatureCursorBuffer as IBufferProcessingParameter;
            bufferProcessingParameter.FeatureClass = pClass1;
            bufferProcessingParameter.AdjustCirclesForProjection = false;
            bufferProcessingParameter.SimplifyShapes = false;
            bufferProcessingParameter.InputHasPolygons = false;
            bufferProcessingParameter.BufferSpatialReference = esriBufferSpatialReferenceType.esriFeatureSetOptimizedSpatialReference;
            bufferProcessingParameter.TargetSpatialReference = esriBufferSpatialReferenceType.esriMapSpatialReference;
            bufferProcessingParameter.SaveAsGraphics = true;
            bufferProcessingParameter.GenerateRings = true;
            #endregion

            IFeatureCursorBuffer2 pFeatureCursorBuffer2 = pFeatureCursorBuffer as IFeatureCursorBuffer2;
            //设置空间参考
            IGeoDataset pGeoDS = pClass1 as IGeoDataset;
            ISpatialReference pSpatialRefOut = pMap.SpatialReference;
            pFeatureCursorBuffer2.BufferSpatialReference = null;
            pFeatureCursorBuffer2.SourceSpatialReference = pGeoDS.SpatialReference;
            pFeatureCursorBuffer2.TargetSpatialReference = pSpatialRefOut;
            pFeatureCursorBuffer2.DataFrameSpatialReference = pSpatialRefOut;

            //生成GraphicsLayer
            ICompositeGraphicsLayer pCompositeGraphicsLayer = new CompositeGraphicsLayerClass();
            pFeatureCursorBuffer2.BufferToGraphics(pCompositeGraphicsLayer);

            IGraphicsContainer pGraphicsContainer = pCompositeGraphicsLayer as IGraphicsContainer;
            pGraphicsContainer.Reset();
            IGraphicsContainerSelect pGraphicsContainerSel = pGraphicsContainer as IGraphicsContainerSelect;
            pGraphicsContainerSel.SelectAllElements();
            IEnumElement pEnumEle = pGraphicsContainerSel.SelectedElements;
            //设置显示样式
            IRgbColor pColorFill = new RgbColorClass();
            pColorFill.Blue = 0;
            pColorFill.Green = 0;
            pColorFill.Red = 122;
            pColorFill.Transparency = 0;

            IRgbColor pColorLine = new RgbColorClass();
            pColorLine.Blue = 0;
            pColorLine.Green = 0;
            pColorLine.Red = 122;
            pColorLine.Transparency = 100;

            ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
            pLineSymbol.Color = pColorLine;
            pLineSymbol.Width = 2;

            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
            pFillSymbol.Color = pColorFill;
            pFillSymbol.Outline = pLineSymbol;

            IElement pEle;
            while ((pEle = pEnumEle.Next()) != null)
            {
                IFillShapeElement pFillShapeEle = pEle as IFillShapeElement;
                pFillShapeEle.Symbol = pFillSymbol;
                IElement pElement = pFillShapeEle as IElement;
                pGeos.AddElement(pElement, 0);
            }
            this.axMapControl1.Refresh();

删除缓冲区的方法是:

IGraphicsContainer.DeleteAllElements

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值