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?