I am trying to write a script to make a tool that will run in Arcmap 10.7.1.
I have a file with multiple different shapefiles with multiple different projections. Basically, it has to take the spatial reference of a specified shapefile and reproject it to all the others. When I run the script (hard-coding the 'arcpy.GetParameterAsText()' variables to test the functionality of the script), I get ERROR 000628: Cannot set input into parameter out_coor_system.
. How can I get around that and make the script functional?
Here is the code I have:
#Import modules
import arcpy, os
#Set workspace directory
from arcpy import env
#Define workspace
inWorkspace = arcpy.GetParameterAsText(0)
env.workspace = inWorkspace
env.overwriteOutput = True
#Define local shape file to reproject to
targetFeature = arcpy.GetParameterAsText(1)
#Describe the input feature class
inFc = arcpy.Describe(targetFeature)
#Define the spatial reference of the input feature class
sRef = inFc.spatialReference.name
#List the feature classes in the workspace
fcList = arcpy.ListFeatureClasses()
#Reproject all the feature classes:
for fc in fcList:
desc = arcpy.Describe(fc)
if desc.spatialReference.name != sRef:
print "Projection of " + str(fc) + " is " + desc.spatialReference.name + ", so re-defining projection now:"
newFc = arcpy.Project_management(fc, desc.name + "_projected", sRef)
arcpy.AddMessage(arcpy.GetMessages())
newFc = arcpy.Describe(newFc)
print str(fc) + " has been reprojected to " + str(newFc.spatialReference.name)
I'm trying to add the "_projected" to the original file name, to signify that it has been reprojected. Also, I'm using IDLE as my IDE.