dtmgis

ITopologicalOperator.Buffer Fails - Error 0x80040239

Discussion created by dtmgis on May 25, 2011
Latest reply on May 25, 2011 by dtmgis
This appears be something that a couple other people have run into going back to 2007 or so.

I am running a simple Buffer on a polygon.  See code below.  This Sub is a simplified version of a much more complex Function, but I've stripped it down to just the basics here to try and figure out what is going on.  This Sub is getting called from another routine that loops through a set of selected polygons, passing the current Feature to the Sub.  On occasion, the "topoOperator.Buffer(iBuffer)" line fails, returning the "0x80040239" Error.  It is ALWAYS on the same polygon, and ONLY when dBufferMiles = 5. If I change the buffer to 4.9 or 5.1, or just about any other number I've tried, the buffer works fine.  If I get rid of the 'convert to miles' text and just enter iBuffer = 8046 (e.g. 5 x 1069.3), it fails.  I've tried numbers slightly above and below 8046 as my buffer and it fails, so it appears to be a range of numbers for the buffer distance that it does not like.

I can select any other polygon and it works fine with a 5 mile buffer.  This is in ArcGIS 10, but it also cropped up occasionally in 9.3.  I'm using a Personal GDB.  I've cleaned the geometry, created a new File GDB, and exported out only that polygon; each with the same results.

I can usually run the Buffer tool from the Geoprocessing menu using a 5 mile buffer dist, but I've even seen that fail the first try, before working on the second try.  If I edit the polygon's vertices, then it will work, though I can't tell you which vertex solved the problem.  And if there was a problem with the geometry, then the Clean Geometry should have taken care of it.

Any thoughts?  This application works flawlessly for tens of thousands of polygons, but for some reason fails with certain polygons at specific buffer distances.  I'm stumped.

-Tony

Public Sub buffTest(ByVal pFeature As IFeature, ByVal pMap As IMap)
        Try
            Dim pLayer As IFeatureLayer
            Dim pCursor As IFeatureCursor = Nothing
            Dim sName As String

            sName = "clonelayer"
            pLayer = FindLayerByName(sName, pMap)

            Dim pFeat4Buff As IFeature
            pFeat4Buff = pFeature
            Dim pGeom As IGeometry = pFeat4Buff.Shape
            Dim topoOperator As ITopologicalOperator = CType(pGeom, ITopologicalOperator)

            Dim iBuffer As Long
            Dim dBufferMiles As Double

            dBufferMiles = 5
            iBuffer = Int(dBufferMiles * 1609.3) 'convert miles to meters.
            'iBuffer = 9000 'convert miles to meters.

            Dim buffer As IGeometry
            buffer = topoOperator.Buffer(iBuffer)
            Dim pArea As IArea
            pArea = buffer
            MsgBox(pArea.Area / 4047, vbNormal, "Buffer Acres")

        Catch ex As Exception
            MsgBox("Buffer Error: " & ex.Message & " - Stack Trace: " & ex.StackTrace, vbInformation, "Buffer Select Error")

        End Try

    End Sub

Outcomes