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:
- This affects the performance (I need to create many thousands of polygons).
- 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.
-
1Are you adding the points in a clockwise direction? Also did, you try IGeometryBridge2.AddPoints?Kirk Kuykendall– Kirk Kuykendall2012年12月05日 19:14:11 +00:00Commented 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.jan_b– jan_b2012年12月06日 07:33:57 +00:00Commented Dec 6, 2012 at 7:33
-
Did you already rule out using the Create Fishnet geoprocessing tool?blah238– blah2382012年12月06日 17:23:03 +00:00Commented 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.jan_b– jan_b2012年12月06日 19:22:12 +00:00Commented Dec 6, 2012 at 19:22
2 Answers 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.
-
easy way for inner rings (inRing) IRing ring = inRing as IRing; ring.ReverseOrientation(); ring.Close();Paulo Moreno– Paulo Moreno2016年11月15日 07:28:47 +00:00Commented 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 answernmtoken– nmtoken2016年11月15日 08:37:59 +00:00Commented Nov 15, 2016 at 8:37
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()
-
I tried this. Closing a polygon helps, i.e. the feature has all four segments but labels are still misplaced...jan_b– jan_b2012年12月05日 12:31:10 +00:00Commented Dec 5, 2012 at 12:31
Explore related questions
See similar questions with these tags.