Move SHP to gdb and ArcView license (newbie frustration)!!!

3142
54
04-11-2012 07:58 AM
LucaMoiana
New Contributor
Hi there,
What I need to do is move all the files into an mxd to a newly created gdb, chechking prj, and update mxd reference.

I have ArcGIS 10 SP4, license ArcView

I studied a bit of Python and get familiar with basic, then I copied some written code and pasted all together, attached is the code.

My frustration is that i can???t even move my shp files to a created gdb, is that because of my ArcView license?

PLEASE PLEASE PLEASE HELP

# 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)
Tags (2)
0 Kudos
54 Replies
MichaelVolz
Esteemed Contributor
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.
0 Kudos
MathewCoyle
Frequent Contributor
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.
0 Kudos
LucaMoiana
New Contributor
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
0 Kudos
LucaMoiana
New Contributor
Thanks again.

Two things: I tried using .prj file path and got same error


Second is that the last part of my script is copied from ESRI HELP SITE:

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000007m000000
0 Kudos
MichaelVolz
Esteemed Contributor
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.
0 Kudos
LucaMoiana
New Contributor
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.


I did try using ESRI code with projection and nothing changes...same error
0 Kudos
MathewCoyle
Frequent Contributor
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")
0 Kudos
LucaMoiana
New Contributor
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....
0 Kudos
MathewCoyle
Frequent Contributor
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.
0 Kudos
LucaMoiana
New Contributor
Post your line of code that is failing. And the transformation parameter is not optional in a lot of cases.


I get the error after:
                # 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))




Here is the error:

Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 000622: Failed to execute (Project). Parameters are not valid. ERROR 000628: Cannot set input into parameter out_coor_system.
0 Kudos