Thanks in advance for any help. I have a feature class in ArcGIS 10.2 with 455 polygons,they are municipal boundaries. We use it to determine permissions for users in another application and it's based on sharing a boundary. So, for example, Muni A touches Muni B and C, so Muni A's rights will be:

-Muni A

-All towns within

-Muni B

--All towns within

-Muni C

--All towns within

It's simple enough to select by location to determine the municipalities that share a boundary, however, I cannot seem to take that selection and do another based on those results to select the town polygons within B and C. Second to that, can you possibly script this to make it iterative so I can generate shp files for said permissions automatically?


This can be easily done in model builder. So you have your selection on the Municipal boundaries (A,B & C). Use that selection to select all towns. This will select all towns in A,B & C. Clear selection on municipals, select A by attribute then do a select by location but removing the selection from the towns, this will leave you selected towns in B & C.

The assumption behind this method is that towns fall entirely within your Municipal polygons.


I pulled the attached script from the ESRI 10.2 Help section on Select Layer By Location (Data Management). You can see how they do an initial select based on location followed by subsetting by attributes. You can replace the select by attributes by a select by location and specify SUBSET_SELECTION.

# Name: ExtactFeaturesByLocationAndAttribute.py
# Description: Extract features to a new feature class based on a Location and an attribute query

# Import arcpy and set path to data
import arcpy
arcpy.env.workspace = "c:/data/mexico.gdb"

# Make a layer and select cities which overlap the chihuahua polygon
arcpy.MakeFeatureLayer_management('cities', 'cities_lyr') 
arcpy.SelectLayerByLocation_management('cities_lyr', 'intersect', 'chihuahua')

# Within the previous selection sub-select cities which have population > 10,000
                                        'SUBSET_SELECTION', '"population" > 10000')

# If features matched criteria write them to a new feature class
matchcount = int(arcpy.GetCount_management('cities_lyr').getOutput(0)) 
if matchcount == 0:
    print('no features matched spatial and attribute criteria')
    arcpy.CopyFeatures_management('cities_lyr', 'chihuahua_10000plus')
    print('{0} cities that matched criteria written to {0}'.format(
                                                  matchcount, chihuahua_10000plus))

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.