2

I am trying to reproject multiple shapefiles in a folder. When I run my program this is the error I am getting:

line 8221, in Project raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000670: output Output Dataset or Feature Class is same as input Input Dataset or Feature Class Failed to execute (Project).

I checked my code and I'm not seeing what Im doing wrong. What could be the issue here?

# Import system modules
import arcpy
import os

# Set environment settings
arcpy.env.workspace = "C:\\users\\data\\shapefile_roads"
arcpy.env.overwriteOutput = True
outWorkspace = "C:\\users\\data\\shapefile_roads"

for infc in arcpy.ListFeatureClasses():

        # Determine if the input has a defined coordinate system, can't project it if it does not
    dsc = arcpy.Describe(infc)

    if dsc.spatialReference.Name == "Unknown":
        print ('skipped this fc due to undefined coordinate system: ' + infc)
    else:
        # Determine the new output feature class path and name
        outfc = os.path.join(outWorkspace, infc)

        # Set output coordinate system
        outCS = arcpy.SpatialReference('WGS 1984')

        # run project tool
        arcpy.Project_management(infc, outfc, outCS)

        # check messages
        print(arcpy.GetMessages())
5

Your output dataset has the same name as your input dataset. Try setting a different workspace for the output, like: outWorkspace = "C:\\users\\data\\shapefile_roads_projected"

  • Ahhh of course. That did the trick! – Paul Edwards May 5 '15 at 15:50
  • What is "overwriteOutput = True" doing then? I have multiple batch copy/convert for loops that I'd like to not to have to make a new output folder for, for each step of the way. I have no need for the intermediate files. – AF2k15 Apr 3 '16 at 22:06
3

Well, the error message is pretty straight forward:

ERROR 000670: output Output Dataset or Feature Class is same as input Input Dataset or Feature Class Failed to execute (Project).

The infc and outfc variables both point to the same feature class.

One easy fix would be to output into a different folder.

So, create a new folder called "projected" within the "shapefile_roads" folder, and change outWorkspace to:

outWorkspace = "C:\\users\\data\\shapefile_roads\\projected"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.