3

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.

asked Dec 5, 2012 at 10:04
4
  • 1
    Are you adding the points in a clockwise direction? Also did, you try IGeometryBridge2.AddPoints? Commented Dec 5, 2012 at 19:14
  • I tried IGeometryBridge2.AddPoints and the result was the same. Adding points in a clockwise direction solved the problem! Thanks Kirk. Commented Dec 6, 2012 at 7:33
  • Did you already rule out using the Create Fishnet geoprocessing tool? Commented Dec 6, 2012 at 17:23
  • Yes, I did. But I need a bit more control over created grid, that's why need to use ArcObjects. Thanks for a hint, though. Commented Dec 6, 2012 at 19:22

2 Answers 2

2

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.

answered Dec 6, 2012 at 16:42
2
  • easy way for inner rings (inRing) IRing ring = inRing as IRing; ring.ReverseOrientation(); ring.Close(); Commented Nov 15, 2016 at 7:28
  • This doesn't seem to answer the original question, rather it appears to be a comment on the original answer Commented Nov 15, 2016 at 8:37
0

Try casting the IPointCollection to an IPolygon and closing it using IPolygon.Close().

You need to use only four vertices (no need to duplicate first and last vertices).

It could be something like below in VBA(not tested)..

pPoint.PutCoords(dX, dY)
pPntColl.AddPoint(pPoint)
dim pPolygon as IPolygon
set pPolygon = pPntColl
pPolygon.Close()
dim pFeature as IFeature
set pFeature = pFeatureClass.CreateFeature()
pFeature.Shape = pPolygon
pFeature.Store()
answered Dec 5, 2012 at 11:48
1
  • I tried this. Closing a polygon helps, i.e. the feature has all four segments but labels are still misplaced... Commented Dec 5, 2012 at 12:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.