Project 2: Batch reprojection tool for vector datasets Penn State

10-02-2014 07:24 AM
New Contributor



This is my first time posting to a discussion board. I am in the process of taking Penn State's Geog 485 course on Python and GIS and I am stuck on an exercise.


Here is the url of the exercise:


If anyone has any suggestion on how to make this code work or what I am doing wrong, I would really appreciate it



import arcpy  #Set workspace environment arcpy.env.workspace = "C:\\Users\\jtodd\\Dropbox\\PennState_OnlineCourses\\WCGIS\\Geog485\\Lesson2\\Lesson2Data"   #Input feature classes input_features = arcpy.ListFeatureClasses()   #Output workspace output_workspace = "C:\\Users\\jtodd\\Dropbox\\PennState_OnlineCourses\\WCGIS\\Geog485\\Lesson2\\Lesson2Data\\results"   #template dataset template = "Ferries.shp"   try:          #Geographic transformation - Determines 'template' spatial reference     desc = arcpy.Describe(template)     templateSR = desc.spatialReference     #print templateSR.Name #Check to make sure code is working up to this point       for featureClass in input_features:         desc = arcpy.Describe(featureClass)         fcListSR = desc.SpatialReference         #print fcListSR.Name #Check to make sure code is working up to this point           if fcListSR.Name != templateSR.Name:             arcpy.DefineProjection_management(input_features, templateSR)             print(arcpy.GetMessages(0))   except arcpy.ExecuteError:     print(arcpy.GetMessages(2))   except Exception as ex:     print(ex.args[0])
0 Kudos
1 Reply
MVP Esteemed Contributor

can you repost the code it is on one line

0 Kudos