[Tutor] Changing spatial reference of shapefiles in folder and exporting to new folder
Michael Omohundro
omohundr at hawaii.edu
Sun Apr 12 01:15:53 CEST 2015
I want to assemble a script to: 1) input a folder with shapefiles with
different coordinate systems, 2) allow the user through a toolbox script to
choose a desired coordinate system, and then 3) export all the shapefiles
with the new coordinate system to a new folder.
So the problem is I don't know how to get the user to choose the coordinate
system they want when I create the script in toolbox.
Here is my code:
import arcpy
arcpy.env.workspace = arcpy.GetParameterAsText(0)
fcList = arcpy.ListFeatureClasses()
try:
inFolder = arcpy.ListFeatureClasses()
template = arcpy.GetParameteAsText(1)
outFolder = arcpy.GetParameterAsText(2)
arcpy.AddMessage(template)
srf = arcpy.Describe(template).spatialReference.name
for fc in fcList:
if srf.Name == "Unknown":
# skip
continue
else:
arcpy.Describe(fc).spatialReference.name != srf.name:
arcpy.Project_management (fc, outFolder + "\\" + fc, desc,
{transform_method}, {in_coor_system})
#
I have attached the window I am making in the toolbox to this email.
I also get this error when I run the script in the toolbox:
SyntaxError: invalid syntax (Final_Proj_DRAFT.py, line 16)Failed to
execute (SpatRefAutomation).
Line 16 of the code reads:
spatialRef = arcpy.Describe(inputFolder).spatialReference
Please help me.
More information about the Tutor
mailing list