2

I tried to use IFeatureCursorBuffer to create and dissolve the buffered features.I am trying to get the solution since some days using dissolve and UnionOverlappingBuffers, but not being able to get it.

Dim bc As IFeatureCursorBuffer  
Dim bgpp As IBasicGeoprocessor   
Dim ptempDS As IDatasetName
Dim ds As IDataset
Dim DissolveBufferLayer As IFeatureLayer
Dim pNewWSName As IWorkspaceName
Dim pdatasetname2 As IDatasetName
Dim tbl As ITable 
Dim pfeatureclassname As IFeatureClassName 
Dim BufferLayerName As String
Dim BufferLayer As IFeatureLayer

Set bc = New FeatureCursorBuffer
bc.PolygonBufferType = esriBufferOutsideIncludeInside
Set bc.featureCursor = BufferLayer.featureClass.update(Nothing, False)
Set bc.spatialReference = TTMap.spatialReference
bc.FieldDistance = BufferDistsanceInMeters
bc.Units(TTMap.MapUnits) = esriMeters
**bc.Dissolve = True**

Set bgpp = New BasicGeoprocessor

BufferLayerName = "DISSOLVE_" & BufferLayerName
CreateShapefile esriGeometryPolygon, ExportFolderPath, BufferLayerName, True

Set DissolveBufferLayer = GetLayerfromLayerName(BufferLayerName)
Set pfeatureclassname = New FeatureClassName
With pfeatureclassname
    .FeatureType = esriFeatureType.esriFTSimple
    .shapeFieldName = "Shape"
    .ShapeType = BufferLayer.featureClass.ShapeType
End With

Set pNewWSName = New WorkspaceName
pNewWSName.WorkspaceFactoryProgID = "esriCore.ShapefileWorkspaceFactory.1"
pNewWSName.PathName = ExportFolderPath & "\"

Set pdatasetname2 = pfeatureclassname
pdatasetname2.Name = DissolveBufferLayer.Name
Set pdatasetname2.WorkspaceName = pNewWSName

Set tbl = BufferLayer.featureClass
Set ds = tbl
Set ptempDS = ds.FullName

If Not tbl Is Nothing Then
    Set newtbl = BufferLayer.featureClass
    Set newtbl = bgpp.Dissolve(tbl, False, "ID", "ID", pdatasetname2)
End If

TTMxdoc.UpdateContents
TTMxdoc.activeView.Refresh

On Error GoTo 0
Exit Function

2 Answers 2

1

Swanand,

This interface is poorly documented by ESRI and requires a whole host of other interfaces to get it working. This is a good example where their documentation (which is usually good) is not sufficient to work out what the hell you are supposed to do with it.

ArcGIS is now at release 10.2 and they still have not improved the documentation on this interface... :(

I would recommend using the GeoProcessor and calling the Buffer tool as I think that would be easiest. Having said that I have managed to work out how to use this complex interface and supplied the VBA code below. One caveat with this code is that the dataframe, input layer and output layer are all in the same coordinate system.

Public Sub test()
On Error GoTo eh

' Create a workspaceName
Dim pWorkspaceName As IWorkspaceName
Set pWorkspaceName = New WorkspaceName
With pWorkspaceName
    .WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory"
    .PathName = "C:\Temp"
End With

' Create a FeatureClassName
Dim pFeatureClassName As IFeatureClassName
Set pFeatureClassName = New FeatureClassName
With pFeatureClassName
    .FeatureType = esriFTSimple
    .ShapeFieldName = "Shape"
    .ShapeType = esriGeometryPolygon
End With

' Create a DatasetName and update properties
Dim pDatasetName As IDatasetName
Set pDatasetName = pFeatureClassName
With pDatasetName
    .Name = "myBuffers.shp"
    Set .WorkspaceName = pWorkspaceName
End With

' Get a handle on a point layer (first in TOC)
Dim pMXDoc As IMxDocument
Set pMXDoc = ThisDocument
Dim pMap As IMap
Set pMap = pMXDoc.FocusMap
Dim pLayer As ILayer
Set pLayer = pMap.Layer(0)
Dim pFeatureLayer As IFeatureLayer
Set pFeatureLayer = pLayer

' Get SpatialReference of layer
Dim pGeoDataset As IGeoDataset
Set pGeoDataset = pFeatureLayer
Dim pSR As ISpatialReference
Set pSR = pGeoDataset.SpatialReference

' Create a cursor over point layer
Dim pFeatureCursor As IFeatureCursor
Set pFeatureCursor = pFeatureLayer.Search(Nothing, False)

' Create a FeatureCursorBuffer2
Dim pFeatureCursorBuffer As IFeatureCursorBuffer2
Set pFeatureCursorBuffer = New FeatureCursorBuffer

' Set parameters of Buffering
Dim pBufferProcessingParameter As IBufferProcessingParameter
Set pBufferProcessingParameter = pFeatureCursorBuffer
With pBufferProcessingParameter
    .AdjustCirclesForProjection = False
    .BufferSpatialReference = esriFeatureSetOptimizedSpatialReference
    Set .FeatureClass = pFeatureLayer.FeatureClass
    .GenerateRings = False
    .InputHasPolygons = False
    .SaveAsGraphics = False
    .SimplifyShapes = False
    .TargetSpatialReference = esriFeatureSetOptimizedSpatialReference
End With

' Set FeatureCursorBuffer and execute
With pFeatureCursorBuffer
    .PolygonBufferType = esriBufferOutsideIncludeInside
    .Dissolve = False
    Set .CancelTrack = Nothing
    Set .FeatureCursor = pFeatureCursor
    .FieldDistance = "PolygonID" ' A numeric field in point layer that dictates size of buffer
    Set .SpatialReference = pSR
    .Units(esriMeters) = esriMeters
    Set .BufferSpatialReference = pSR ' Specific to the IFeatureCursorBuffer2 interface
    Set .DataFrameSpatialReference = pSR ' Specific to the IFeatureCursorBuffer2 interface
    Set .TargetSpatialReference = pSR ' Specific to the IFeatureCursorBuffer2 interface
    .Buffer pFeatureClassName ' This line executes the Buffering process
End With
Exit Sub
eh:
    Debug.Print Err.Description
End Sub
1
  • Thank you for your help. I also found another method to dissolve the buffers. Created buffers in VBA and then passed the buffer layer to the dissolve tool from Python ArcToolbox.
    – Swanand
    Commented Sep 25, 2013 at 8:48
0

@Hornbydd Thank you for your help.

I also found another method to dissolve the buffers. I created buffers in VBA and then passed the buffer layer to the dissolve tool from Python ArcToolbox as input.

Public Function DissolveBuffer(InputPath As String, OutputPath As String) As IFeatureLayer

'Create the Geoprocessor object
Dim GP As Object
Set GP = CreateObject("esriGeoprocessing.GpDispatch.1")

'Execute tools
GP.Dissolve InputPath, OutputPath

TTMxdoc.UpdateContents
TTMxdoc.activeView.Refresh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.