Help please with buffering

Feb 15, 2011 at 6:42 PM

Hello all,

I have a problem in my code and I really need your help please. It is a basic code for creating buffers from a polygon shape file and inserting the buffer polygons in a new shape file.

When I debug the code, I get an error saying "Found Null Directory Edge. The code is below and the error occurs in the line highlighted in red..

Dim numShapesBuild As Integer
Dim buildSF As New MapWinGIS.Shapefile()
bufferSF.Open("build.shp")
numShapesBuild = buildSF.NumShapes

Dim bufferSF As New MapWinGIS.Shapefile()
bufferSF.Open("buf.shp")

Dim myBufferShape as MapWinGIS.Shape()

bufferSF.StartEditingShapes(True)

For shapeNum = 0 To numShapesBuild - 1
myBufferShape = New MapWinGIS.Shape
myBufferShape.Create(MapWinGIS.ShpfileType.SHP_POLYGON)
MapWinGeoProc.SpatialOperations.BufferShape(buildSF.Shape(shapeNum), 5.0, myBufferShape)
bufferSF.EditInsertShape(myBufferShape, bufferSF.NumShapes - 1)
Next

bufferSF.StopEditingShapes()



Also I tried the shape.Buffer function and it is giving me an error as well "External component has thrown an exception".

The code below for that is similar to the one above except for using shape.Buffer function instead of MapWinGeoProc.SpatialOperations.BufferShape

Dim numShapesBuild As Integer
Dim buildSF As New MapWinGIS.Shapefile()
bufferSF.Open("build.shp")
numShapesBuild = buildSF.NumShapes

Dim bufferSF As New MapWinGIS.Shapefile()
bufferSF.Open("buf.shp")

Dim myBufferShape as MapWinGIS.Shape()

bufferSF.StartEditingShapes(True)

For shapeNum = 0 To numShapesBuild - 1
                    myBufferShape = New MapWinGIS.Shape
                    myBufferShape.Create(MapWinGIS.ShpfileType.SHP_POLYGON)
                    myBufferShape = buildSF.Shape(shapeNum).Buffer(5,4)
                    bufferSF.EditInsertShape(myBufferShape, bufferSF.NumShapes - 1)
Next

bufferSF.StopEditingShapes()


 

Your help is really appreciated.

Thank you,