# Import system modules import arcpy from arcpy import env import os # Set environment settings env.workspace = "C:/Users/a391665/Documents/AAAAPERSONALE/rugareto" # Execute CreateFileGDB arcpy.CreateFileGDB_management("C:/park", "test4") # Set local variables outWorkspace = "c:/park/test4.gdb" # Use ListFeatureClasses to generate a list of shapefiles in the # workspace shown above. fcList = arcpy.ListFeatureClasses() # Execute CopyFeatures for each input shapefile for shapefile in fcList: # Determine the new output feature class path and name outFeatureClass = os.path.join(outWorkspace, shapefile.strip(".shp")) arcpy.CopyFeatures_management(shapefile, outFeatureClass)
I think this is one place, amongst many, where ESRI can improve the error messages in python.
The error message "Runtime error <type 'exceptions.RuntimeError'>: ERROR 999999: Error executing function" is so generic that it is hard to pinpoint what the exact problem is with the code. It would have been nice if the error message could inform the developer that it was looking for a prj file and not a text string that was representing the name of the projection.
I agree, error catching could be improved greatly. In this case though, it seems to me more a problem with how spatial reference objects are passed in tools as strings. By having strings as object inputs, it is very difficult for error catching to determine what is wrong with your string, just it wasn't the string it was expecting. For error catching, I would find it great if they would at least give you an index number of the input that crapped out the tool, as opposed to failing the tool entirely.
Thanks again.
Two things: I tried using .prj file path and got same error
Luca:
If this is the case, then are you sure the spatial reference in the line below is legitimate.
outCS = arcpy.SpatialReference('WGS 1984 UTM Zone 32N')
Try running your code with the projection from ESRI's example and see if it also errors out on that. If not, then it might be the syntax of the projection you are using.
I hope this helps.
installdir = arcpy.GetInstallInfo("desktop") outCS = arcpy.SpatialReference(installdir["InstallDir"]+r"Coordinate Systems\Projected Coordinate Systems\UTM\WGS 1984\Northern Hemisphere\WGS 1984 UTM Zone 32N.prj")
This works fine for me.installdir = arcpy.GetInstallInfo("desktop") outCS = arcpy.SpatialReference(installdir["InstallDir"]+r"Coordinate Systems\Projected Coordinate Systems\UTM\WGS 1984\Northern Hemisphere\WGS 1984 UTM Zone 32N.prj")
Thanks! That at least create a outCS but still I can't project cause I get this error "Runtime error <class 'arcgisscripting.ExecuteError'>: Undefined geographic transformation. " while on the hel guide says that transformation is an option parameter....
Post your line of code that is failing. And the transformation parameter is not optional in a lot of cases.
# Create a spatial reference object using a projection file outCS = arcpy.SpatialReference(installdir["InstallDir"]+r"Coordinate Systems\Projected Coordinate Systems\UTM\WGS 1984\Northern Hemisphere\WGS 1984 UTM Zone 32N.prj") #outCS = arcpy.SpatialReference('WGS_1984_UTM_Zone_32N') print "outCS CREATED!" arcpy.Project_management(fc, outfc, outCS) print "PROJECTED!" for ws in arcpy.ListWorkspaces(): fcs_in_workspace(os.path.join(workspace, ws))