I am wanting to create a ArcPy Tool Script that will join a point file to multiple polygons. Ideally, the point file (input_fc) would be a parameter so it can be interchangeable. Then the polygons would be in one geodatabase (CensusGDB)(the files will be Census Blocks, Block Groups, Tracts and Counties). The output geodatabase would also be a parameter (out_gdb).
The final output would be one point file with just the key field for each of these files that were joined. This is what I have so far, doing the first spatial join, but will need the output of this first spatial join output to be the input for the next spatial joins.
##Spatial Join Census geographies
import arcpy
import os
CensusGDB = r"C:\Census_All.gdb"
out_gdb = arcpy.GetParameterAsText(1)
#Input the point feature class
input_fc = arcpy.GetParameterAsText(0)
out_fc = os.path.join(out_gdb, 'name')
#List the featureclasses within the Census gdb
arcpy.env.workspace = CensusGDB
featureclasses = arcpy.ListFeatureClasses()
# for fc in featureclasses:
for fc in featureclasses:
desc = arcpy.Describe(fc)
fc_path =os.path.join(CensusGDB,desc.name)
out_fc = os.path.join(out_gdb,desc.name)
##Start Spatial Joins
arcpy.analysis.SpatialJoin(target_features =input_fc,join_features=fc_path,output_feature_class = out_fc)
Any ideas on if this is the right way to go or if I need to try something else?