I'm trying to use the spatial join to append rows to my target feature from my join feature. Here's my code:

#import the module
import arcpy
from arcpy.sa import *
from arcpy import env
env.overwriteOutput = True

#set the workspace
arcpy.env.workspace = r"C:\Users\Windows\Documents\JO_GIS_Analyst"

#Adding the municipality to the attribute table
for fc in arcpy.ListFeatureClasses("reclassnofptphil_onlyreprojected_2014121_geog*"):
    print fc #checking of feature classes
    outputFeature = "withjoin" + fc # specify output feature
    arcpy.SpatialJoin_analysis(fc, "PHL_adm2_UTM.shp", outputFeature)

print "Finish"

I'm getting an error of:

Traceback (most recent call last):
File "C:\Users\Windows\Dropbox\Python Scripts\batch_convert_raster_to_polygon.py", line 71, in <module>
arcpy.SpatialJoin_analysis(fc, "PHL_adm2_UTM.shp", outputFeature)
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\analysis.py", line 481, in SpatialJoin
raise e
ExecuteError: ERROR 999999: Error executing function.
Item not found in this collection.
Failed to execute (SpatialJoin).

Here is the ouput of the print statement:


Actually I'm doing a loop for six files only, since I'm just using my sample files to test my code.

closed as off-topic by PolyGeo Dec 23 '16 at 7:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    That's a VERY long name for a feature class, try it with a shorter name... Is PHL_adm2_UTM.shp in your current workspace ("C:\Users\Windows\Documents\JO_GIS_Analyst")? if not it will not find it, use the full path. – Michael Stimson Aug 26 '14 at 5:19
  • Yes, PHL_adm2_UTM.shp is in the current workspace. – brentiemapper Aug 26 '14 at 6:10
  • I think you should try running the Spatial Join tool manually from its tool dialog with exactly the same parameter values that your script is supplying. – PolyGeo Aug 26 '14 at 6:22
  • Hello, I checked the output file shapefile and it seemed that my code worked but the error 999999 returned. – brentiemapper Aug 26 '14 at 6:30
  • Maybe, there is a problem with the implementation of my for loop, since only a single fc is processed, and the script returns an error. – brentiemapper Aug 26 '14 at 7:47