I am trying to join two lists of feature class files from seperate folders into a new folder. I've been successful spatially joining a single file but cannot figure out how to list files from folder 1, files form folder 2 - and then join them together. He is what I have tried so far:
# Import Packages import arcpy,os,sys,string from arcpy import env from arcpy.sa import * #Call the Spatial license arcpy.CheckOutExtension("Spatial") #Define the outfolder outFolder = r"C:\OutFolder" #Set working environment and list files from folder one env.workspace = r"C:\Folder1" #List Files from Folder 1 featureclasses = arcpy.ListFeatureClasses() for inFeature1 in featureclasses: print inFeature1 #Set working environment and list files from folder two env.workspace = r"C:\Folder2" #List Files from Folder 2 featureclasses = arcpy.ListFeatureClasses() for inFeature2 in featureclasses: print inFeature2 #Create file names for tne joined file outFeature = outFolder + "/" + inFeature2 arcpy.SpatialJoin_analysis(inFeature1, inFeature2, outFeature, "JOIN_ONE_TO_ONE", "KEEP_ALL", "", "INTERSECT", "", "") print "done"
Here is the error I am getting:
Target Features: Dataset 20180201.shp does not exist or is not supported Failed to execute (SpatialJoin).
I think the error has something to so with the filenames possible being the same between the two folders. At the very least, I know the ordering of my lists and the application of the function are incorrect.
New error after code update:
Target Features: Dataset \wrrs1\Student Homes\Group Projects\TRMM_GPM_Showdown\DiffFiles\Joined Final\20180201.shp does not exist or is not supported Failed to execute (SpatialJoin).