Sounds messy doesn’t it? And in fact it can be.
Have you ever zoomed in on a map document that included polygons with a solid fill symbolization and reached a point where the full display is suddenly covered with the fill symbol color? As if the polygon symbolization “leaked” out of the polygon boundary and spilled into the rest of your map?
Here’s an example to illustrate. First we see a normal building footprint polygon with a solid “Rose” color symbol.
Then we zoom it to an area where our building falls partly in and partly outside the map display and, to quote Emeril Lagasse, “Boom” everything outside the building is now rose… and everything inside the building is not.
What’s going on here?
Well, what we just saw is that ArcGIS really wants polygons to be created using points defined in a clockwise direction. The building polygon in the example above had its points defined counter-clockwise.
If we’re creating polygons inside ArcMap/ArcFM the clockwise-ness is established for us, as can be illustrated by a simple experiment. Below we purposely create a polygon defining points counter-clockwise.
If we then double-click on our new building polygon and inspect the vertices we’ll see that the ArcMap polygon constructor has reversed the order of our points, so while we created it in a counter-clockwise direction the points as stored are clockwise.
So, now that we know what’s going on, what do we do about it?
There are steps we can take to correct polygons that have been defined incorrectly. Also, if we’re responsible for creating the polygons in the first place, there are steps we can take to ensure polygons are created correctly in the first place.
Correcting Polygons with Invalid Geometry
Similar to a condition addressed also in this site (Repairing Invalid [Network Feature] Geometries) Esri has anticipated cases of counter-clockwise polygons (as well as other invalid geometry conditions) and provided a Geoprocessing Tool named “Repair Geometry”. Find this in ArcToolbox either in ArcMap or AcrCatalog under “Data Management | Features”.
When executed on the feature class with the invalid building polygon we can see that “Repair Geometry” addressed our counter-clockwise ordering issue, as well as several other invalid geometry conditions in the feature class.
On careful examination we see that the ordering issue is referred to as “incorrect ring ordering” which reflects the fact that a polygon geometry may be composed of multiple “rings” — think the state of Hawaii — and further that some rings may be interior to others — think Dunkin Donuts.
Avoiding Creation of Polygons with Invalid Geometry
In the case where we are creating polygons programmatically based on some requirement, such as creating container polygons or creating ArcFM Underground Facilities Manager (UFM) manhole wall features from manhole floors or any other condition ensuring the geometry we build is valid is pretty straightforward. Esri provides an interface available on most geometry types called ITopologicalOperator that has a method named Simplify. Per the ArcObjects on-line reference, the Simplify method:
“…permanently alters the input geometry, making its definition “topologically legal” with respect to its geometry type”
Which for polygons, ensures its exterior is defined in a clock-wise direction. Here’s a simple code snippet to illustrate.