I have two feature classes one with points one with polygons (in ArcMap 10.2). Now, I want to write into a String Field of the polygon layer a list of all the Point-FIDs that are within each polygon (often more than one, which is why join doesn't help). I was hoping that there is a possibility using Field Calculator and somehow concatenate the FIDs but I don't know how to access the other feature class within the calculation code

Is that possible?

3 Answers 3


Use the Spatial Join tool with Match Option set to CONTAINS, instead of the Field Calculator.

Spatial Join (Analysis)


Joins attributes from one feature to another based on the spatial relationship. The target features and the joined attributes from the join features are written to the output feature class.


@PolyGeo's solution will work, but here is how to do it with just Spatial Join (and Add/Calculate Field if you need the FID, which needs to be copied to a real field for this to work). This will almost certainly be faster than using nested cursors.

  1. If you need a FID from a shapefile, use Add Field followed by Calculate Field to first copy the FID field to a new user-defined field, because Spatial Join does not allow you to join FID because it is not a real field.
  2. In the Spatial Join tool, select the ONE_TO_ONE relationship type (this still lets us concatenate all the spatially related records, just with one output record per target record).
  3. In the Field Map, for the field(s) that you want to get a concatenated list of values, right-click the output field and click Properties.
  4. Select 'Join' for the merge rule and enter the desired delimiter, e.g. a comma.

Beware that if there are many values being concatenated this can very easily go over field length limits, resulting in an error.


This Python script should do what you are after once you have substituted your feature class and field names into it.

import arcpy

arcpy.MakeFeatureLayer_management(r"C:\temp\test.gdb\PolyFC", "PolyLayer")
arcpy.MakeFeatureLayer_management(r"C:\temp\test.gdb\PointFC", "PointLayer")

rows = arcpy.UpdateCursor("PolyLayer")

# iterate through each polygon in PolyLayer
for row in rows:
    polygon = row.SHAPE
    # intersect polygon geometry with points to get list of point OBJECTIDs
    # use search cursor to read selected points
    selectedPoints = arcpy.SearchCursor("PointLayer")
    objectidList = ""
    for selectedPoint in selectedPoints:
        objectidList = objectidList + "," + str(selectedPoint.OBJECTID)
    # write OBJECTID list to the polygon attribute
    # called (PointIDs which is text field added)
    # lstrip() used to get rid of leading comma
    row.PointIDs = objectidList.lstrip(",")
del row,rows

To do the same thing using Data Access (arcpy.da) cursors, which were new at 10.1 and thus available to you, is slightly more complicated and probably gives little performance gain in this instance so I stayed with this code which will also work at 10.0.

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.