I realize this is a little old, but I did write a variant of spatial join for the use case you are discussing. It can integrate into model builder workflows and the python sample is there.
ArcNumerical-Tools/NumericalSpatialJoin.py at master · Holisticnature/ArcNumerical-Tools · GitHub
Let me know if you have any questions.
import arcpy arcpy.env.overwriteOutput = True targetFeatures = r'C:\data.gdb\bufferLayer' joinFeatures = r'C:\data.gdb\censusTracts' outputFeatures = r'C:\data.gdb\spatialJoinOutput' # create a list of fields to sum fieldNamesToSum = ['CENSUS_FIELD_TO_SUM_1', 'CENSUS_FIELD_TO_SUM_2'] # create the field mapping object fieldMappings = arcpy.FieldMappings() # populate the field mapping object with the fields from both feature classes fieldMappings.addTable(targetFeatures) fieldMappings.addTable(joinFeatures) # loop through the field names to sum for fieldName in fieldNamesToSum: # get the field map index of this field and get the field map fieldIndex = fieldMappings.findFieldMapIndex(fieldName) fieldMap = fieldMappings.getFieldMap(fieldIndex) # update the field map with the new merge rule (by default the merge rule is 'First') fieldMap.mergeRule = 'Sum' # replace with the updated field map fieldMappings.replaceFieldMap(fieldIndex, fieldMap) arcpy.SpatialJoin_analysis(targetFeatures, joinFeatures, outputFeatures, "JOIN_ONE_TO_ONE", "KEEP_ALL", fieldMappings, "INTERSECT", "", "")
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.