I have the following two datasets:

  • polygon shapefile containing administrative boundaries of a City
  • multiple point shapefiles

What I want to do is to spatially join the point shapefiles with the polygon based on the match_option intersect using arcpy. So to say, I want to count the number of Features per Point shapefile in the polygon shapefile. I do not Need any fields of the Point shapefils, but only the join_count field.

This is the Python script I have so far.

output = 'F:\\test\\spatialJoin'
pointShpfiles = listofShapefiles.split(";")  
spatialJoin = administrativeUnits
for pointShp in pointShpfiles:  
    spatialJoin = arcpy.SpatialJoin_analysis(spatialJoin, pointShp, arcpy.Polygon, "JOIN_ONE_TO_ONE", "KEEP_ALL", "dummyField", "INTERSECT")
    arcpy.DeleteField_management(spatialJoin, 'dummyField')
    arcpy.DeleteField_management(spatialJoin, 'TARGET_FID') 
arcpy.CopyFeatures_management(spatialJoin, output)

The script works partly, but the Problem is, that only the last of the Point shapefiles in the list is added, so I only have one join_count field instead of 3 (for three entered Point shapefiles).

What I am doing wrong?

1 Answer 1


I found out why only the current join_count was added. This is due to the dummyField that was added, meaning this was the only field that was preserved, all others were deleted, also the previous join_counts.

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.