Similar to this question,

I have two datasets that consist of points and polygons, where all the points are inside the polygons. The polygon IDs (called cluster IDs) were previously joined with the points to reflect which polygon each point "belonged" to; or which polygon the point is located in. The points have attributes that include DOY and the cluster ID. So, they can essentially be grouped by cluster ID.

I would like to separate the polygon dataset into 3 subsets: 1) polygons contain points that have only 1 unique DOY value (for example, there are 5 points within a polygon but only 1 is unique), 2) polygons contain points that have more than one unique value (for example, a polygon contains 5 points and 2 are unique), and 3) polygons contain points where no DOY values are unique (all values are identical).

I have already used the "Find Identical" tool in ArcGIS Pro to get subset #2, where the output is a table. I can then identify the identical points, select only the points with matching cluster IDs from the original shapefile, and select the polygons that intersect these points. However, I am not sure how to separate out subset #3 from #2. How can I parse out whether some values are identical (subset #2) versus whether ALL are identical (subset #3)? Is there another tool that would make this easier? For subset #1, it seems like I could just invert this relationship to find all the polygons that do NOT intersect with subset #2 or #3.

Alternately, if there is a tool or workflow that would allow me to count distinct/unique point DOY values within each polygon, that would probably be much simpler.

1 Answer 1


So this is your starting scenario as you describe:


A simple model as such will populate the subset field


The code in the Calculate Value tool is:

import arcpy
def ComputeSubSet(layer):
    # Read DOY values into a SET object
    aSet = set()
    with arcpy.da.SearchCursor(layer,["DOY"]) as cursor:
        for row in cursor:
    # Determine what subset the points belong to
    n = len(aSet)
    if n == 2:
        subset = 1
    elif n > 2:
        subset = 2
    elif n == 1:
        subset = 3
    return subset

The calculate value tool is set up as:

Calculate value tool



You can then use the Join Field tool to join the subset back to the polygons.

The code works by using a Set object in Python which can only hold unique values and its the count on the set that determines if it is in subset 1, 2 or 3.

As a side note when asking question its helpful to include images to explain your problem as large blocks of text are difficult to unravel when a simple picture explains it all...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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