[GIS] Problem creating polygon features using ArcObjects / ArcGIS 10

arcgis-10.0arcobjectspolygonpolygon-creation

I need to create a grid of polygons. Each polygon is rectangle, thus has 4 corners (vertices). When I create polygon features using ArcObjects they seem to have wrong geometry, which results in wrong label placement (outside polygons).

I use the following approach:

Dim pPntColl As IPointCollection
pPntColl = New Polygon

Dim pPoint As IPoint
pPoint = New Point
pPoint.PutCoords(dX, dY)
pPntColl.AddPoint(pPoint)

...

When I use 4 vertices I get a polygon which has one segment missing (visible in Edit session).
polygon made of 4 points

When I add the first point at the end of polygon (as a 5th point), geometry looks good, but the label is still off.

polygon made of 5 points

I know I can use ITopologicalOperator2 and Simplify() method but:

  1. This affects the performance (I need to create many thousands of polygons).
  2. I don't understand, what is the reason of the problem. I have 4 points, they should create a topologically correct polygons…

So, my question is: what is the best way of creating polygon features within a polygon feature class using ArcObjects?

I already checked some ESRI recommended approaches, e.g.:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//0001000002wm000000
but the problem is still the same: I need to use Simplify() to get polygons right.

Any help and hints how to optimize this will be appreciated.

Best Answer

Add the points in a clockwise order.

When you call IPointCollection.AddPoint, on a polygon the point is added to the exterior ring of the polygon. Vertices in exterior rings are expected to be clockwise, so if you don't add them in clockwise order ArcObjects will need to do more work to re-order them.

Interior rings (e.g. donut holes) are counter-clockwise.

Related Question