Skip to main content
Corrected English
Source Link
Hornbydd
  • 44.6k
  • 5
  • 42
  • 84

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 simplysimple 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!)

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 simply 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!)

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!)
Source Link
Hornbydd
  • 44.6k
  • 5
  • 42
  • 84

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 simply 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!)