9

Some 3rd party software cannot handle polygons with holes (donut polygons). To find them I always use ArcView 3 field calculator, because:

enter image description here

however when I try to do this in ArcGIS, I get this:

enter image description here

So the question is how to make it right in ArcGIS.

  • I was surprised partcount didn't work as expected, so I did some digging. Turns out that apparently donuts can sometimes(?) be single part features with inner rings - see the sentence/graphic before the last code block at this page. I also saw a thread about a script that would detect them in python, but not in the field calculator. – Chris W Feb 11 '15 at 20:40
  • I can do it using a code block, but it is ugly. Main lines prt=shp.getPart(0) feat=arcpy.Polygon(prt). It is enough to calculate feat.area and compare it to shp.area – FelixIP Feb 11 '15 at 20:53
  • Related resource: gis.stackexchange.com/questions/27255 Your area comparison solution may be ugly, but it seems like it works and within Field Calculator. Might be worth posting as an answer. – Chris W Feb 11 '15 at 20:54
  • I'd rather give credits to @Hornbydd, because his answer compares integers, my own (which I knew long ago) deals with doubles – FelixIP Feb 11 '15 at 21:08
18

Part count will not yield the correct answer. You could have a multi-part polygon with no holes. See image below for scenario.

Multi-part polygons

This would have been a simple query pre-ArcGIS 10 as you could have called ArcObjects to ask if the polygon had a hole but ESRI have removed much of this support in the VBScripting environment to the point its pretty useless now, bit of a shame really...

Anyway you can solve this question with some Python:

def hasHole(geom):
  parts = geom.partCount
  boundaries = geom.boundary().partCount
  if boundaries > parts:
    return 1
  else:
    return 0

In the expression box you would place the following:

hasHole(!Shape!)
  • Thanks for elegant answer. The one I used in absence of ArcView 3 was less reliable, see my comments to @ChrisW – FelixIP Feb 11 '15 at 21:22
1

Are you referring to the difference between the two expressions? If yes, it looks like the bottom one is using Python as the parser where as the one on top is using VB. To change this in the Field Calculator window in ArcGIS, just select VB instead of Python and the top expression should work.

  • What is the expression in VB please – FelixIP Feb 11 '15 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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