Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to update some code from VB6 to VB.Net 2008 and have been generally successful. However, I came across an issue where, as it processes each polygon in the shapefile, it implements the following code.

Dim lngExtRing as Integer lngExtRing = pPolygon.ExteriorRingCount - 1
ReDim pExtRings(pPolygon.ExteriorRingCount - 1) pPolygon.QueryExteriorRingsEx(pPolygon.ExteriorRingCount, pExtRings(0)) pExtRings(lngExtRing)

Once that code runs and you hover over the pExtRings portion of pExtRings(lngExtRing) for some polygons (not all), the first popup lists a ComObject but if you expand the plus, it indicates "Nothing".

I have run this on a shapefile that has 5 polygons and the two polygons that it fails on have negative areas. There are two ways that might resolve this, but I don't know how to implement either. One was to reverse the orientation if the area was negative, but I tried that on a different shapefile and it still failed on a polygon that did not have a negative area. The other, perhaps better, approach would be to implement the RepairGeometry class of ESRI.ArcGIS.DataManagementTools, but I have no clue on how to make it happen.

If anyone has any insight or examples of how to use RepairGeometry, I would certainly appreciate being enlightened.

Thanks

Dale

share|improve this question
    
there is s specific order as to direction for each descending ring in esri topology. could that have anything to do with it? Maybe a direction to look. –  Brad Nesom Jan 7 '11 at 14:23
    
I guess my confusion comes in regarding how the direction of the polygon is established. Does it have to do with the actual direction that it is drawn or is it assigned by Arc when it is stored? –  Dale Bridgford Jan 7 '11 at 20:04
add comment

2 Answers


There are two things I can suggest:

  1. Are you using IPolygon interface or IPolygon4? Because in ESRI documentation it says IPolygon.ExteriorRingCount() does not work in .Net, use IPolygon4 instead
  2. Do you have slightest idea about the direction of digitization of these problem polygons? Again, as per ESRI, inner rings are characterized by a counterclockwise orientation

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/InteriorRingCount_Property/002m000002nt000000/
Cheers!

share|improve this answer
    
ujjwalesri, thanks for the reply. It has been some time since I have tried to wrestle this to the ground. In the next month or so, I should have time to work on this project again. Thanks, Dale –  Dale Bridgford May 20 '11 at 12:27
add comment

Instead of running the Repair Geometry GP tool, you could use ITopologicalOperator.Simplify since you are already in ArcObjects code.

Before the code you're showing in your question, do something like

Dim topop As ITopologicalOperator = pPolygon
topop.Simplify()

Simplify corrects any topological errors including incorrect ring orientation.

share|improve this answer
    
Philip, Turns out I am not failing on bad geometry, but a polygon that is merged from 2 separate polygons (e.g., Editor->Merge). Now I need to figure out how to deal with those instances. Thanks, –  Dale Bridgford Feb 2 '11 at 17:08
    
Don't forget to make the topop.IsKnownSimple false first, a geometry is sometime considered simple even when it isn't, and simplify will not do anything if the geometry is considered simple. see the doc help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… –  MathiasWestin May 19 '11 at 9:18
    
Mathias, thanks for the reply. It has been some time since I have tried to wrestle this to the ground. In the next month or so, I should have time to work on this project again. Thanks, Dale –  Dale Bridgford May 20 '11 at 12:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.