How to write this line in vb.net

394
2
06-14-2012 05:17 AM
JoseSanchez
Occasional Contributor III
How to write this line in vb.net with a IGeoprocessor


    # Create a Polygon object based on the array of points
    #
    polygon = arcpy.Polygon(array)

thanks
0 Kudos
2 Replies
DuncanHornby
MVP Notable Contributor
You would do something like:

Dim pPolygon as IPolygon
pPolygon = new polygon
Dim pPointcoll as IPointCollection
pPointcoll =pPolygon

Creat your points:

dim pPoint as IPoint
pPoint = new Point
pPoint.x = 1
pPoint.Y=1

Then you add your points to build the polygon:

pPointcoll.Add(pPoint)

Duncan
0 Kudos
JoseSanchez
Occasional Contributor III
Thanks

I also have found this sample  http://resources.esri.com/help/9.3/ArcGISDesktop/dotnet/4aac10e4-d44d-4dc3-a7b4-5edae04798b3.htm

Case esriGeometryType.esriGeometryPolygon
    Dim poly As IPolygon = New Polygon
    Dim pointColl As IPointCollection = CType(poly, IPointCollection)
    pointColl.AddPoint(lowLeft)
    pointColl.AddPoint(lowRight)
    pointColl.AddPoint(upRight)
    pointColl.AddPoint(upLeft)
    Dim maware As IMAware = CType(poly, IMAware)
    maware.MAware = True
    poly.Close()
    Dim topoOp2 As ITopologicalOperator2 = CType(pointColl, ITopologicalOperator2)
    If topoOp2.IsKnownSimple = True Then
        topoOp2.Simplify()
        Dim polyExt As IFeature = CreateFeature(featClass, poly)
    End If

0 Kudos