AnsweredAssumed Answered

Batch Re-projection script syntax error

Question asked by salmanseahmed on Jan 21, 2015
Latest reply on Jan 23, 2015 by salmanseahmed

I have started learning Python for ArcGIS last week and have a simple script to reproject all the datasets in a folder. The script says "syntax error- invalid syntax" but I can't find anything. Can someone please have a look? It seems something very basic but I'm pretty new so I don't see it at the moment. Also running this in ArcGIS prints "failed" right away. And the files are in place in the right folders. I have already checked.

 

import arcpy

... sourceWorkspace = "C:\\Users\\tx8p90\\Desktop\\Lesson2"

... targetProjection = "C:\\Users\\tx8p90\\Desktop\\python excercise data\\Lesson1\\contourlines.shp"

... listDataSet = arcpy.ListDatasets(sourceWorkspace)

... try:

...     for x in listDataset:

...         outputDataset = sourceWorkspace + "\\projected_" + x

...         arcpy.Project_management(x, outputDataset, targetProjection)

...         print "Reprojection successful"

... except:

...     print arcpy.GetMessages()

...     print "failed"

Outcomes