宇辉刘文清家庭成员:怎么用mapx中BufferFeatures创建缓冲区,我需要代码

来源:百度文库 编辑:神马品牌网 时间:2024/04/30 10:45:55

Description:

This sample buffers each selected feature in the focus map and stores the results as polygon graphic elements in the map's basic graphics layer. Products:

ArcView: VBA

Platforms: Windows

Minimum ArcGIS Release: 9.0

How to use:

Paste the code into VBA.

Load one or more feature layers.

Select some features.

From the Macros dialog, run the BufferFeatures macro.

Public Sub BufferFeatures() Dim pMxDoc As IMxDocument Dim pActiveView As IActiveView Dim pGraphicsContainer As IGraphicsContainer Dim pEnumFeature As IEnumFeature Dim pFeature As IFeature Dim pTopoOp As ITopologicalOperator Dim pElement As IElement Dim strBufferDistance As String Set pMxDoc = Application.Document Set pActiveView = pMxDoc.FocusMap Set pGraphicsContainer = pMxDoc.FocusMap 'Verify there is a feature selection If pMxDoc.FocusMap.SelectionCount = 0 Then Exit Sub 'Get a buffer distance from the user strBufferDistance = InputBox("Enter Distance:", "Buffer") If strBufferDistance = "" Or Not IsNumeric(strBufferDistance) Then Exit Sub 'Buffer all the selected features by the BufferDistance 'and create a new polygon element from each result Set pEnumFeature = pMxDoc.FocusMap.FeatureSelection pEnumFeature.Reset Set pFeature = pEnumFeature.Next Do While Not pFeature Is Nothing Set pTopoOp = pFeature.Shape Set pElement = New PolygonElement pElement.Geometry = pTopoOp.Buffer(CInt(strBufferDistance)) pGraphicsContainer.AddElement pElement, 0 Set pFeature = pEnumFeature.Next Loop 'Redraw the graphics pActiveView.PartialRefresh esriViewGraphics, Nothing, NothingEnd Sub