+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 50 of 55

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

  1. #1
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    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

    Code:
    # 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)

  2. #2
    Darren Wiens

    Join Date
    Apr 2011
    Posts
    821
    Points
    271
    Answers Provided
    37


    0

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

    What does the error say (if any)? It shouldn't have anything to do with your licenses, both tools you use are available to ArcView.

    edit: maybe try:
    Code:
    arcpy.CopyFeatures_management(shapefile, outWorkspace + os.sep + shapefile.rstrip(".shp"))
    Last edited by dkwiens; 04-11-2012 at 08:19 AM.

  3. #3
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Thank you!
    here is the error I get when I run it on Python, even after your edit suggestion:

    "Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset Percorsi.shp does not exist or is not supported Failed to execute (CopyFeatures). "

    Quote Originally Posted by dkwiens View Post
    What does the error say (if any)? It shouldn't have anything to do with your licenses, both tools you use are available to ArcView.

    edit: maybe try:
    Code:
    arcpy.CopyFeatures_management(shapefile, outWorkspace + os.sep + shapefile.rstrip(".shp"))

  4. #4
    Scott Blankenbeckler
    Join Date
    Aug 2010
    Posts
    115
    Points
    7
    Answers Provided
    2


    0

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

    I would try changing the following section of code

    Code:
    # 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"
    to

    Code:
    # 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"
    Scott Blankenbeckler
    Computer Systems Analyst III (GIS)

    Points: 7 <--- How did this happen?

  5. #5
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Thank you Scott I did it, here is the error on Python Window:

    Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset Percorsi.shp does not exist or is not supported Failed to execute (CopyFeatures).

    And here is what I get from PythonWin interactive window:

    Traceback (most recent call last):
    File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
    exec codeObject in __main__.__dict__
    File "C:\Users\a391665\Desktop\Script2.py", line 10, in <module>
    arcpy.CreateFileGDB_management("C:\\park", "test4")
    File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 9453, in CreateFileGDB
    raise e
    ExecuteError: ERROR 000258: Output C:\park\test4.gdb already exists
    Failed to execute (CreateFileGDB).



    Quote Originally Posted by ScottB View Post
    I would try changing the following section of code

    Code:
    # 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"
    to

    Code:
    # 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"

  6. #6
    Scott Blankenbeckler
    Join Date
    Aug 2010
    Posts
    115
    Points
    7
    Answers Provided
    2


    0

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

    Quote Originally Posted by lucamoiana View Post
    ExecuteError: ERROR 000258: Output C:\park\test4.gdb already exists
    Failed to execute (CreateFileGDB).
    Go to your C:\park directory and delete the test4.gdb and rerun the script
    Scott Blankenbeckler
    Computer Systems Analyst III (GIS)

    Points: 7 <--- How did this happen?

  7. #7
    Darren Wiens

    Join Date
    Apr 2011
    Posts
    821
    Points
    271
    Answers Provided
    37


    0

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

    Do you have a file called "Percorsi.shp"? In the folder "C:/Users/a391665/Documents/AAAAPERSONALE/rugareto"?

    Also, after you import os, check if the gdb exists. If it does, delete it.
    Code:
    if os.path.exists("c:/park/test4.gdb"):
        arcpy.Delete_management("c:/park/test4.gdb")
    Last edited by dkwiens; 04-11-2012 at 08:47 AM.

  8. #8
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Sorry guys, I noticed.

    Your help is so precious.
    I wasn't able to add the "overwrite..." but I deleted the gdb and got it working from the PythonWin.
    Although I have this error in the Python Win:
    Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset Percorsi.shp does not exist or is not supported Failed to execute (CopyFeatures).
    >>>


    Quote Originally Posted by dkwiens View Post
    Do you have a file called "Percorsi.shp"? In the folder "C:/Users/a391665/Documents/AAAAPERSONALE/rugareto"?

    Also, after you import os, check if the gdb exists. If it does, delete it.
    Code:
    if os.path.exists("c:/park/test4.gdb"):
        arcpy.Delete_management("c:/park/test4.gdb")

  9. #9
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    Luca:

    Can you add some print statements into your code to see that each step completes successfully?

    eg: print("fcList completed successfully") after the line fcList = arcpy.ListFeatureClasses()

    In addition, maybe print out the name of each featureclass in your fcList as there might be other data types in that folder such as a file geodatabase.

    Darren's comment to check for the existence of the gdb would be helpful as you would need to delete the gdb each time as it gets created early on in your python script.

  10. #10
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    I do have Percorsi.shp but it doesn't seem to work.


    Quote Originally Posted by lucamoiana View Post
    Sorry guys, I noticed.

    Your help is so precious.
    I wasn't able to add the "overwrite..." but I deleted the gdb and got it working from the PythonWin.
    Although I have this error in the Python Win:
    Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset Percorsi.shp does not exist or is not supported Failed to execute (CopyFeatures).
    >>>

  11. #11
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    it work in PythonWin, but in the Python Window I get this:


    env.workspace completed successfully
    CreateFileGDB completed successfully
    outWorkspace completed successfully
    fcList completed successfully
    Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset Percorsi.shp does not exist or is not supported Failed to execute (CopyFeatures).

    Quote Originally Posted by lucamoiana View Post
    I do have Percorsi.shp but it doesn't seem to work.

  12. #12
    Scott Blankenbeckler
    Join Date
    Aug 2010
    Posts
    115
    Points
    7
    Answers Provided
    2


    0

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

    What kind of data is stored in Percorsi.shp? Point? Line? Poly? other? Have you checked to see if the shapefile is corrupt? Also make sure the file is not in use elsewhere.
    Last edited by ScottB; 04-11-2012 at 09:14 AM.
    Scott Blankenbeckler
    Computer Systems Analyst III (GIS)

    Points: 7 <--- How did this happen?

  13. #13
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    Luca:

    Can you add a print statement for each feature class that you loop through in the specified directory? This might be a clue of a problem with the shapefile name.

  14. #14
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Percorsi.shp is a polyline shape, I can get it into gdb running the script from PythonWin but from the Python window I get this:

    env.workspace completed successfully
    CreateFileGDB completed successfully
    outWorkspace completed successfully
    fcList completed successfully
    Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset Percorsi.shp does not exist or is not supported Failed to execute (CopyFeatures).

    Quote Originally Posted by mvolz47 View Post
    Luca:

    Can you add a print statement for each feature class that you loop through in the specified directory? This might be a clue of a problem with the shapefile name.

  15. #15

    Join Date
    Apr 2012
    Posts
    2
    Points
    0
    Answers Provided
    0


    0

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

    What does the error say (if any)?

  16. #16
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Quote Originally Posted by Eleanor62 View Post
    What does the error say (if any)?
    env.workspace completed successfully
    CreateFileGDB completed successfully
    outWorkspace completed successfully
    fcList completed successfully
    Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset Percorsi.shp does not exist or is not supported Failed to execute (CopyFeatures).

  17. #17
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    here is what I was able to accomplish (thank to your help obviously):

    Code:
    # Import system modules
    import arcpy
    from arcpy import env
    import os
    
        
    # Set environment settings
    env.workspace = "C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto\\GIS"
    print("env.workspace completed successfully")
    
    #check GDB exist
    if os.path.exists("c:\\park\\test4.gdb"):
        arcpy.Delete_management("c:\\park\\test4.gdb")
    
    # Execute CreateFileGDB
    arcpy.CreateFileGDB_management("C:\\park", "test4")
    print("CreateFileGDB completed successfully")
    
    # Set local variables
    outWorkspace = "c:\\park\\test4.gdb"
    print("outWorkspace completed successfully")
    
    # Iterate
    def fcs_in_workspace(workspace):
        arcpy.env.workspace = workspace
        for fc in arcpy.ListFeatureClasses():
            print os.path.join(workspace, fc)
            arcpy.FeatureClassToGeodatabase_conversion(fc, outWorkspace)     
            #arcpy.CopyFeatures_management(fc, "c:\\park\\test4.gdb")
            print os.path.join(workspace, fc, "TO GDB")
        for ws in arcpy.ListWorkspaces():
            fcs_in_workspace(os.path.join(workspace, ws))
    
    fcs_in_workspace("C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto\\GIS")
    I dunno why, but in the first try I was able to use "arcpy.CopyFeatures_management" but in this script looping through the subfolders I only can get it working with "arcpy.FeatureClassToGeodatabase_conversion"

  18. #18
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    Luca:

    Can you add the print statement for the feature classes in fcList earlier on in the loop before python hits the error?

    Here is where I would put additional print statements for debugging purposes:
    # Execute CopyFeatures for each input shapefile
    for shapefile in fcList:
    # Determine the new output feature class path and name
    print("The feature class " + shapefile + " now has the focus")
    outFeatureClass = os.path.join(outWorkspace, shapefile.strip(".shp"))
    print("The path to the feature class that has the focus is " + outFeatureClass)
    arcpy.CopyFeatures_management(shapefile, outFeatureClass)

    You might need to change shapefile and outFeatureClass variables to strings if python says they are not in the correct format to be printed out. I think this might provide some additional clues to the problem of python seeing the shapefile that you want copied into the file geodatabase.

  19. #19
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    I don't get it, if I add your code I have an error in line 1.
    Take a look at the last code posted, that works except "arcpy.CopyFeatures_management"


    Quote Originally Posted by mvolz47 View Post
    Luca:

    Can you add the print statement for the feature classes in fcList earlier on in the loop before python hits the error?

    Here is where I would put additional print statements for debugging purposes:
    # Execute CopyFeatures for each input shapefile
    for shapefile in fcList:
    # Determine the new output feature class path and name
    print("The feature class " + shapefile + " now has the focus")
    outFeatureClass = os.path.join(outWorkspace, shapefile.strip(".shp"))
    print("The path to the feature class that has the focus is " + outFeatureClass)
    arcpy.CopyFeatures_management(shapefile, outFeatureClass)

    You might need to change shapefile and outFeatureClass variables to strings if python says they are not in the correct format to be printed out. I think this might provide some additional clues to the problem of python seeing the shapefile that you want copied into the file geodatabase.

  20. #20
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    Can you provide a screenshot of the error message you get, as well as the latest version of the code that you are running?

  21. #21
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    This code works:

    Code:
    # Import system modules
    import arcpy
    from arcpy import env
    import os
    
        
    # Set environment settings
    env.workspace = "C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto"
    print("env.workspace completed successfully")
    
    #check GDB exist
    if os.path.exists("c:\\park\\test4.gdb"):
        arcpy.Delete_management("c:\\park\\test4.gdb")
    
    # Execute CreateFileGDB
    arcpy.CreateFileGDB_management("C:\\park", "test4")
    print("CreateFileGDB completed successfully")
    
    # Set local variables
    outWorkspace = "c:\\park\\test4.gdb"
    print("outWorkspace completed successfully")
    
    # Iterate
    def fcs_in_workspace(workspace):
        arcpy.env.workspace = workspace
        for fc in arcpy.ListFeatureClasses():
            print os.path.join(workspace, fc)
            arcpy.FeatureClassToGeodatabase_conversion(fc, outWorkspace)     
            print os.path.join(workspace, fc, "TO GDB")
        for ws in arcpy.ListWorkspaces():
            fcs_in_workspace(os.path.join(workspace, ws))
    
    fcs_in_workspace("C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto")
    If I use this: arcpy.CopyFeatures_management(fc, outWorkspace)
    I don't get any error but the gdb is empty.
    If I add:
    Code:
    # Iterate
    def fcs_in_workspace(workspace):
        arcpy.env.workspace = workspace
        for fc in arcpy.ListFeatureClasses():
            print os.path.join(workspace, fc)
            outFeatureClass = os.path.join(outWorkspace, fc.strip(".shp"))
            arcpy.CopyFeatures_management(fc, outWorkspace)     
            print os.path.join(workspace, fc, "TO GDB")
        for ws in arcpy.ListWorkspaces():
            fcs_in_workspace(os.path.join(workspace, ws))
    
    fcs_in_workspace("C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto")
    I get this:
    Traceback (most recent call last):
    File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
    exec codeObject in __main__.__dict__
    File "C:\Users\a391665\Desktop\Script2_subfolders_test.py", line 13, in <module>
    arcpy.Delete_management("c:\\park\\test4.gdb")
    File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 3031, in Delete
    raise e
    ExecuteError: ERROR 000601: Cannot delete c:\park\test4.gdb. May be locked by another application.

    Not that I care about CopyFeatures_managment but it seems to be fast, when I sue it out of this script obviously

  22. #22
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    Luca:

    Can you provide the feedback you get for both scenarios from the print statements?

    Also, for the code where you get ERROR 000601, can you make sure you do not have the file geodatabase that you are trying to delete open in ArcMap or ArcCatalog on your computer as that might be putting a lock on the file geodatabase. You also might want to close out of the application that you are running python through as well (e.g. IDLE or pythonwin) as that might also have a lock on the file geodatabase if you had an error in the middle of running the script.

  23. #23
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Ok, deleted gbd, closed alla application, except for PythonWin.
    As said, if I only add " arcpy.CopyFeatures_management(fc, outWorkspace)" it works smoothly but the gdb is empty.
    If I run this code:

    Code:
    # Import system modules
    import arcpy
    from arcpy import env
    import os
    
        
    # Set environment settings
    env.workspace = "C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto"
    print("env.workspace completed successfully")
    
    #check GDB exist
    if os.path.exists("c:\\park\\test4.gdb"):
        arcpy.Delete_management("c:\\park\\test4.gdb")
    
    # Execute CreateFileGDB
    arcpy.CreateFileGDB_management("C:\\park", "test4")
    print("CreateFileGDB completed successfully")
    
    # Set local variables
    outWorkspace = "c:\\park\\test4.gdb"
    print("outWorkspace completed successfully")
    
    # Iterate
    def fcs_in_workspace(workspace):
        arcpy.env.workspace = workspace
        for fc in arcpy.ListFeatureClasses():
            print os.path.join(workspace, fc)
            outFeatureClass = os.path.join(outWorkspace, fc.strip(".shp"))
            arcpy.CopyFeatures_management(fc, outWorkspace)     
            print os.path.join(workspace, fc, "TO GDB")
        for ws in arcpy.ListWorkspaces():
            fcs_in_workspace(os.path.join(workspace, ws))
    
    fcs_in_workspace("C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto")
    I get this error:
    >>> env.workspace completed successfully
    CreateFileGDB completed successfully
    outWorkspace completed successfully
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\Percorsi.shp
    Traceback (most recent call last):
    File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
    exec codeObject in __main__.__dict__
    File "C:\Users\a391665\Desktop\Script2_subfolders_test.py", line 34, in <module>
    fcs_in_workspace("C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto")
    File "C:\Users\a391665\Desktop\Script2_subfolders_test.py", line 29, in fcs_in_workspace
    arcpy.CopyFeatures_management(fc, outWorkspace)
    File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 1943, in CopyFeatures
    raise e
    ExecuteError: Failed to execute. Parameters are not valid.
    ERROR 000725: Output Feature Class: Dataset c:\park\test4.shp already exists.
    Failed to execute (CopyFeatures).


    Quote Originally Posted by mvolz47 View Post
    Luca:

    Can you provide the feedback you get for both scenarios from the print statements?

    Also, for the code where you get ERROR 000601, can you make sure you do not have the file geodatabase that you are trying to delete open in ArcMap or ArcCatalog on your computer as that might be putting a lock on the file geodatabase. You also might want to close out of the application that you are running python through as well (e.g. IDLE or pythonwin) as that might also have a lock on the file geodatabase if you had an error in the middle of running the script.

  24. #24
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    Luca:

    In the line arcpy.CopyFeatures_management(fc, outWorkspace) can you change fc to outFeatureClass

    Also can you move the statement print os.path.join(workspace, fc, "TO GDB") above

    the statement arcpy.CopyFeatures_management(fc, outWorkspace) as this is where the error is occurring.

  25. #25
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Done, and here is the error I get:

    >>> env.workspace completed successfully
    CreateFileGDB completed successfully
    outWorkspace completed successfully
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\Percorsi.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\Percorsi.shp\TO GDB
    Traceback (most recent call last):
    File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
    exec codeObject in __main__.__dict__
    File "C:\Users\a391665\Desktop\Script2_subfolders_test.py", line 34, in <module>
    fcs_in_workspace("C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto")
    File "C:\Users\a391665\Desktop\Script2_subfolders_test.py", line 30, in fcs_in_workspace
    arcpy.CopyFeatures_management(outFeatureClass, outWorkspace)
    File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 1943, in CopyFeatures
    raise e
    ExecuteError: Failed to execute. Parameters are not valid.
    ERROR 000732: Input Features: Dataset c:\park\test4.gdb\Percorsi does not exist or is not supported
    ERROR 000725: Output Feature Class: Dataset c:\park\test4.shp already exists.
    Failed to execute (CopyFeatures).
    Quote Originally Posted by lucamoiana View Post
    Ok, deleted gbd, closed alla application, except for PythonWin.
    As said, if I only add " arcpy.CopyFeatures_management(fc, outWorkspace)" it works smoothly but the gdb is empty.
    If I run this code:

    Code:
    # Import system modules
    import arcpy
    from arcpy import env
    import os
    
        
    # Set environment settings
    env.workspace = "C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto"
    print("env.workspace completed successfully")
    
    #check GDB exist
    if os.path.exists("c:\\park\\test4.gdb"):
        arcpy.Delete_management("c:\\park\\test4.gdb")
    
    # Execute CreateFileGDB
    arcpy.CreateFileGDB_management("C:\\park", "test4")
    print("CreateFileGDB completed successfully")
    
    # Set local variables
    outWorkspace = "c:\\park\\test4.gdb"
    print("outWorkspace completed successfully")
    
    # Iterate
    def fcs_in_workspace(workspace):
        arcpy.env.workspace = workspace
        for fc in arcpy.ListFeatureClasses():
            print os.path.join(workspace, fc)
            outFeatureClass = os.path.join(outWorkspace, fc.strip(".shp"))
            arcpy.CopyFeatures_management(fc, outWorkspace)     
            print os.path.join(workspace, fc, "TO GDB")
        for ws in arcpy.ListWorkspaces():
            fcs_in_workspace(os.path.join(workspace, ws))
    
    fcs_in_workspace("C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto")
    I get this error:
    >>> env.workspace completed successfully
    CreateFileGDB completed successfully
    outWorkspace completed successfully
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\Percorsi.shp
    Traceback (most recent call last):
    File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
    exec codeObject in __main__.__dict__
    File "C:\Users\a391665\Desktop\Script2_subfolders_test.py", line 34, in <module>
    fcs_in_workspace("C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto")
    File "C:\Users\a391665\Desktop\Script2_subfolders_test.py", line 29, in fcs_in_workspace
    arcpy.CopyFeatures_management(fc, outWorkspace)
    File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 1943, in CopyFeatures
    raise e
    ExecuteError: Failed to execute. Parameters are not valid.
    ERROR 000725: Output Feature Class: Dataset c:\park\test4.shp already exists.
    Failed to execute (CopyFeatures).

  26. #26
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    Luca:

    In the ESRI documentation for CopyFeatures_management, the first required parameter is the input feature which looks correct. The second required parameter is the output feature class. It looks like you are providing a workspace instead of the name of the output feature class.

  27. #27
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Sorry, as said I am a total newbie. I got what you say but, what should I put there if not the gdb name?


    Quote Originally Posted by mvolz47 View Post
    Luca:

    In the ESRI documentation for CopyFeatures_management, the first required parameter is the input feature which looks correct. The second required parameter is the output feature class. It looks like you are providing a workspace instead of the name of the output feature class.

  28. #28
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Quote Originally Posted by lucamoiana View Post
    Sorry, as said I am a total newbie. I got what you say but, what should I put there if not the gdb name?
    Here is the link to the example I used...
    http://help.arcgis.com/en/arcgisdesk...00000035000000

  29. #29
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    Try putting in outWorkspace + "\\" + fc.strip(".shp"). You might have issues with "\ as an escape character so you might want to change your code to use / instead of \ as this is the full path to the output feature class including its name.

    I would also strongly advise getting some ESRI training on python scripting if your manager allows this. You would speed up your python scripting learning curve tremendously.

  30. #30
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    That's embarassing, I had some Python training (via webcourse) but apparently ain't enough...
    This is my side project, to get new skills.
    I did as suggested and it works fine for a while, then I get the following error (SHP are the ones I used to test the precious scripts):

    >>> env.workspace completed successfully
    CreateFileGDB completed successfully
    outWorkspace completed successfully
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\Percorsi.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\Percorsi.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\test.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\test.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\test2.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\test2.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_agricole_comuni.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_agricole_comuni.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_boschi_comuni.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_boschi_comuni.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_boschi_comuni_ptishp_pti.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_boschi_comuni_ptishp_pti.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_boschi_comuni_ptishp_pti2.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_boschi_comuni_ptishp_pti2.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_boschi_lat_comuni.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_boschi_lat_comuni.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_boschi_lat_comuni_Proje.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_boschi_lat_comuni_Proje.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_dusaf_comuni.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_dusaf_comuni.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_urb_comuni.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_urb_comuni.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_urb_comuni_Project.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\clip_urb_comuni_Project.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\rugareto.gdb\whitewash_mask
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\rugareto.gdb\whitewash_mask\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\rugareto.gdb\Comuni_rugareto
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\rugareto.gdb\Comuni_rugareto\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\rugareto.gdb\Rugareto
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\rugareto.gdb\Rugareto\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\rugareto.gdb\Buffer_confine
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\rugareto.gdb\Buffer_confine\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\rugareto.gdb\Rugareto_Buffer
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\DataForArcPad1\rugareto.gdb\Rugareto_Buffer\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\GIS\Maratona\ARANCIO.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\GIS\Maratona\ARANCIO.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\GIS\Maratona\BLU.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\GIS\Maratona\BLU.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\GIS\Maratona\ROSSO.shp
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\GIS\Maratona\ROSSO.shp\TO GDB
    C:\Users\a391665\Documents\AAAAPERSONALE\rugareto\GIS\Maratona\RUGARETO.shp
    Traceback (most recent call last):
    File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
    exec codeObject in __main__.__dict__
    File "C:\Users\a391665\Desktop\Script2_subfolders_test.py", line 34, in <module>
    fcs_in_workspace("C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto")
    File "C:\Users\a391665\Desktop\Script2_subfolders_test.py", line 32, in fcs_in_workspace
    fcs_in_workspace(os.path.join(workspace, ws))
    File "C:\Users\a391665\Desktop\Script2_subfolders_test.py", line 32, in fcs_in_workspace
    fcs_in_workspace(os.path.join(workspace, ws))
    File "C:\Users\a391665\Desktop\Script2_subfolders_test.py", line 29, in fcs_in_workspace
    arcpy.CopyFeatures_management(fc, outWorkspace + "\\" + fc.strip(".shp"))
    File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 1943, in CopyFeatures
    raise e
    ExecuteError: Failed to execute. Parameters are not valid.
    ERROR 000725: Output Feature Class: Dataset c:\park\test4.gdb\RUGARETO already exists.
    Failed to execute (CopyFeatures).

    Quote Originally Posted by mvolz47 View Post
    Try putting in outWorkspace + "\\" + fc.strip(".shp"). You might have issues with "\ as an escape character so you might want to change your code to use / instead of \ as this is the full path to the output feature class including its name.

    I would also strongly advise getting some ESRI training on python scripting if your manager allows this. You would speed up your python scripting learning curve tremendously.

  31. #31
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    Luca:

    You get the error because you had already copied a feature class with that name from a file geodatabase in the directory that you were looping through. If you only want to process shapefiles into the new file geodatabase, then you need to filter out data based on its source (only process shapefiles). I hope this helps.

  32. #32
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Ok, I can understand that but, why if I change the code as below, I get the resulting gdb without error?

    BTW thank to you and the all forum thing I am learning A LOT

    Code:
    def fcs_in_workspace(workspace):
        arcpy.env.workspace = workspace
        for fc in arcpy.ListFeatureClasses():
            print os.path.join(workspace, fc)
            arcpy.FeatureClassToGeodatabase_conversion(fc, "c:\\park\\test4.gdb") 
            #outFeatureClass = os.path.join(outWorkspace, fc.strip(".shp"))
            #arcpy.CopyFeatures_management(fc, outWorkspace + "\\" + fc.strip(".shp"))     
            print os.path.join(workspace, fc, "TO GDB")
    Quote Originally Posted by lucamoiana View Post
    That's embarassing, I had some Python training (via webcourse) but apparently ain't enough...
    This is my side project, to get new skills.
    I did as suggested and it works fine for a while, then I get the following error (SHP are the ones I used to test the precious scripts):

  33. #33
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    Luca:

    I believe the ESRI documentation for FeatureClassToGeodatabase_conversion answers this question

    http://help.arcgis.com/en/arcgisdesk...00000021000000

    •The name of the output feature classes will be based on the name of the input feature class name. For example, if the input is C:\base\streams.shp, the output feature class will be named streams.

    •If the name already exists in the output geodatabase, a number will be appended to the end to make it unique, for example, "_1".

    Using FeatureClassToGeodatabase_conversion works properly because when it hits an input feature class with the same name it appends a _1 to the name of the second instance and so on _2 for the third instance instead of throwing an error.

  34. #34
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Great, then I'll use that tool so I won't loose any data.
    Thank you for your precious help.
    Now I am gonna move to the next steps:
    -deal with names starting with numbers;
    -check shp projection.

    Any reading suggestions??

    have a great friday!

    Quote Originally Posted by mvolz47 View Post
    Luca:

    I believe the ESRI documentation for FeatureClassToGeodatabase_conversion answers this question

    http://help.arcgis.com/en/arcgisdesk...00000021000000

    •The name of the output feature classes will be based on the name of the input feature class name. For example, if the input is C:\base\streams.shp, the output feature class will be named streams.

    •If the name already exists in the output geodatabase, a number will be appended to the end to make it unique, for example, "_1".

    Using FeatureClassToGeodatabase_conversion works properly because when it hits an input feature class with the same name it appends a _1 to the name of the second instance and so on _2 for the third instance instead of throwing an error.

  35. #35
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    OK, now I'm working on projection.
    Following is my last code, it works fine as long as all the features are already in the indicated prj; but I get this error

    Runtime error <class 'arcgisscripting.ExecuteError'>: Undefined geographic transformation.
    when the projection is different. Do I have to specify the transformation method?
    if so, how do I deal with transformation?

    Thanks from the new python junkie

    Code:
    # Import system modules
    import arcpy
    from arcpy import env
    import os
    import traceback
    
        
    # Set environment settings
    env.workspace = "C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto\\GIS"
    print("env.workspace completed successfully")
    
    #check GDB exist
    if os.path.exists("c:\\park\\test4.gdb"):
        arcpy.Delete_management("c:\\park\\test4.gdb")
    
    # Execute CreateFileGDB
    arcpy.CreateFileGDB_management("C:\\park", "test4")
    print("CreateFileGDB completed successfully")
    
    # Set local variables
    outWorkspace = "c:\\park\\test4.gdb"
    print("outWorkspace completed successfully")
    
    # Iterate
    def fcs_in_workspace(workspace):
        arcpy.env.workspace = workspace
        for fc in arcpy.ListFeatureClasses():
                dsc = arcpy.Describe(fc)
                if dsc.spatialReference.name == "WGS_1984_UTM_Zone_32N":               
                    print os.path.join(workspace, fc, "prj: WGS_1984_UTM_Zone_32N")
                    arcpy.FeatureClassToGeodatabase_conversion(fc, "c:\\park\\test4.gdb") 
                    print os.path.join(workspace, fc, "importaed in GDB")
                else:
                    print os.path.join(workspace, fc, "DIFFERENT PRJ!")
                    # Determine the new output feature class path and name
                    #outfc = os.path.join(workspace, fc)
                    # Set output coordinate system
                    #prjFile = "C:\\Program Files\\ArcGIS\\Desktop10.0\\Coordinate Systems\\Projected Coordinate Systems\\UTM\\WGS 1984\\Northern Hemisphere\\WGS 1984 UTM Zone 32N.prj"
                    print "PRJ CREATED!"
                    # Create a spatial reference object using a projection file
                    outCS = arcpy.SpatialReference("C:\\Program Files\\ArcGIS\\Desktop10.0\\Coordinate Systems\\Projected Coordinate Systems\\UTM\\WGS 1984\\Northern Hemisphere\\WGS 1984 UTM Zone 32N.prj")
                    print "outCS CREATED!"
                    arcpy.Project_management(fc, "c:\\park\\test4.gdb", outCS)
                    print "PROJECTED!"
        for ws in arcpy.ListWorkspaces():
            fcs_in_workspace(os.path.join(workspace, ws))
    
    fcs_in_workspace("C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto\\GIS")

  36. #36
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    Luca:

    I would first check to see if the prj file is correct. Take one of the feature classes in your file geodatabase and set it to the indicated projection within ArcMap or ArcCatalog. If this fails, it might indicate an issue with your prj file.

    Also, are these feature classes already in a projection. If so, maybe you do not need to use the arcpy.SpatialReference method, but go directly to arcpy.Project_management. I have a python script where I reproject multiple feature classes in a loop which already have a projection and I just use the arcpy.Project_management method to accomplish this task.

  37. #37
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Quote Originally Posted by mvolz47 View Post
    Luca:

    I would first check to see if the prj file is correct. Take one of the feature classes in your file geodatabase and set it to the indicated projection within ArcMap or ArcCatalog. If this fails, it might indicate an issue with your prj file.

    Also, are these feature classes already in a projection. If so, maybe you do not need to use the arcpy.SpatialReference method, but go directly to arcpy.Project_management. I have a python script where I reproject multiple feature classes in a loop which already have a projection and I just use the arcpy.Project_management method to accomplish this task.
    Hi!
    Sorry for the late reply but I am out of office.
    The prj file is correct and I can correctly use it in the toolbox project tool, I tried to convert the very same file and it worked just fine.
    The shp files already have projection, but I do need to set a Spatial reference, as in the help script example:
    http://help.arcgis.com/en/arcgisdesk...0000007m000000

  38. #38
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    Luca:

    I just looked at the script that I use to reproject feature classes and I pass a string representation of the out_coor_system, as opposed to the .prj file that you are using.

    Maybe you can get the string representation of the out_coor_system instead of the .prj file and see if that works. My out_coor_system is different from yours so it would not help you.

    If you say using the .prj file in an out-of-the-box tool worked, but the python script did not work then you might want to log an incident with ESRI Technical support as I would think both instances are running the same behind the scenes code.

    Also in my script, I need to add the appropriate toolboxes in order for the python script to run as below:
    # Load required toolboxes...
    arcpy.AddToolbox("C:/Program Files (x86)/ArcGIS/Desktop10.0/ArcToolbox/Toolboxes/Data Management Tools.tbx")

    Your path to the toolbox might be slightly different depending upon your operating system.

    I hope this info helps.

  39. #39
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Really getting nervous on this...
    I loaded
    # Load required toolboxes...
    arcpy.AddToolbox("C:/Program Files (x86)/ArcGIS/Desktop10.0/ArcToolbox/Toolboxes/Data Management Tools.tbx")
    But nothing changes.

    Following is my new code, the scripts stops at
    # Create a spatial reference object using a projection file
    outCS = arcpy.SpatialReference('WGS 1984 UTM Zone 32N')
    And the error is:

    Runtime error <type 'exceptions.RuntimeError'>: ERROR 999999: Error executing function.
    Code:
    # Import system modules
    import arcpy
    from arcpy import env
    import os
    import traceback
    # Load required toolboxes...
    arcpy.AddToolbox("C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\ArcToolbox\\Toolboxes\\Data Management Tools.tbx")
    
        
    # Set environment settings
    env.workspace = "C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto\\GIS\\test"
    print("env.workspace completed successfully")
    
    #check GDB exist
    if os.path.exists("c:\\park\\test4.gdb"):
        arcpy.Delete_management("c:\\park\\test4.gdb")
    
    # Execute CreateFileGDB
    arcpy.CreateFileGDB_management("C:\\park", "test4")
    print("CreateFileGDB completed successfully")
    
    # Set local variables
    outWorkspace = "c:\\park\\test4.gdb"
    print("outWorkspace completed successfully")
    
    # Iterate
    def fcs_in_workspace(workspace):
        arcpy.env.workspace = workspace
        for fc in arcpy.ListFeatureClasses():
                dsc = arcpy.Describe(fc)
                if dsc.spatialReference.name == "WGS_1984_UTM_Zone_32N":               
                    print os.path.join(workspace, fc, "prj: WGS_1984_UTM_Zone_32N")
                    arcpy.FeatureClassToGeodatabase_conversion(fc, "c:\\park\\test4.gdb") 
                    print os.path.join(workspace, fc, "importaed in GDB")
                else:
                    print os.path.join(workspace, fc, "DIFFERENT PRJ!")
                    # Determine the new output feature class path and name
                    outfc = os.path.join(outWorkspace, fc)
                    # Set output coordinate system
                    #prjFile = "C:\\Program Files\\ArcGIS\\Desktop10.0\\Coordinate Systems\\Projected Coordinate Systems\\UTM\\WGS 1984\\Northern Hemisphere\\WGS 1984 UTM Zone 32N.prj"
                    print "PRJ CREATED!"
                    # Create a spatial reference object using a projection file
                    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))
    
    fcs_in_workspace("C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto\\GIS\\test")

  40. #40
    Mathew Coyle

    Join Date
    Feb 2011
    Posts
    1,369
    Points
    958
    Answers Provided
    150


    0

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

    You need to reference a projection file, not a projection name.
    Mathew Coyle, EADA10
    GIS Analyst
    Alberta-Pacific Forest Industries Inc.
    ArcGIS 10.2.1 Testing
    ArcGIS 10.1 SP1
    Windows 7 SP1 64-bit

  41. #41
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    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.

  42. #42
    Mathew Coyle

    Join Date
    Feb 2011
    Posts
    1,369
    Points
    958
    Answers Provided
    150


    0

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

    Quote Originally Posted by mvolz47 View Post
    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.
    Mathew Coyle, EADA10
    GIS Analyst
    Alberta-Pacific Forest Industries Inc.
    ArcGIS 10.2.1 Testing
    ArcGIS 10.1 SP1
    Windows 7 SP1 64-bit

  43. #43
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Quote Originally Posted by mzcoyle View Post
    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

  44. #44
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Quote Originally Posted by lucamoiana View Post
    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/arcgisdesk...0000007m000000

  45. #45
    Michael Volz
    Join Date
    May 2010
    Posts
    1,351
    Points
    173
    Answers Provided
    21


    0

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

    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.

  46. #46
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Quote Originally Posted by mvolz47 View Post
    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

  47. #47
    Mathew Coyle

    Join Date
    Feb 2011
    Posts
    1,369
    Points
    958
    Answers Provided
    150


    0

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

    This works fine for me.
    Code:
    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")
    Mathew Coyle, EADA10
    GIS Analyst
    Alberta-Pacific Forest Industries Inc.
    ArcGIS 10.2.1 Testing
    ArcGIS 10.1 SP1
    Windows 7 SP1 64-bit

  48. #48
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Quote Originally Posted by mzcoyle View Post
    This works fine for me.
    Code:
    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....

  49. #49
    Mathew Coyle

    Join Date
    Feb 2011
    Posts
    1,369
    Points
    958
    Answers Provided
    150


    0

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

    Quote Originally Posted by lucamoiana View Post
    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.
    Mathew Coyle, EADA10
    GIS Analyst
    Alberta-Pacific Forest Industries Inc.
    ArcGIS 10.2.1 Testing
    ArcGIS 10.1 SP1
    Windows 7 SP1 64-bit

  50. #50
    Luca Moiana
    Join Date
    Apr 2010
    Posts
    53
    Points
    0
    Answers Provided
    0


    0

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

    Quote Originally Posted by mzcoyle View Post
    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:
    Code:
                    # 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.

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts