[GIS] Selecting MultiPart Polygons if there are buildings in at least two of the parts

arcgis-desktoparcpymultipartpolygonpython

my data situation:

shape of polygons (some are MultiPart Poylgons)
shape of building locations (Points)

What I need:
Select all polygons that have two ore more parts and contain one building or more in at least two of the parts.

What I did so far:

  1. I added and calculated a field that tells me if a poylgon has multiple parts.
    Field calculator Python: !shape.isMultipart!

  2. I calculated of how many parts each MultiPart Polygon consists.
    Field calculator Python: !Shape!.partCount

Now I have all the MultiPart Polygons with two or more parts selected.
From this point, how can I select only the polygons that contain a building in at least two of their parts?

PS: I'm working with ArcGIS

Best Answer

Someone may be able to provide a better workflow, but here's mine:

1) Your polygons up to now probably look something like this.

Start

2) Explode or use the Multipart to Singlepart tool to convert them into singlepart polygons.

Exploded

3) Select by Location the exploded (singlepart) polygons that intersect the points and export as a new feature class.

Select by LocationSelected Polygons

4) With the selected polygon feature class, run a Frequency on how many UnqiueID or ORIG_FID frequency values occurred more than once. These UniqueIDs/ORIG_FIDs are your answer.

FrequencyResult

5) You can Join the frequency table to your original multipart polygon feature class to create your selection query. Something like PartCount > 1 AND FREQUENCY > 1.

Join

Let us know if this works, or if someone else has an easier solution feel free to contribute.