I am trying to convert the feature classes in data.gdb to a new PCS per the code on this webpage:
import arcpy import os arcpy.env.workspace = "G:/W135thStCopy/data.gdb" arcpy.env.overwriteOutput = True outWorkspace = "G:/W135thStCopy/data_WebMerc.gdb" try: for infc in arcpy.ListFeatureClasses(): dsc = arcpy.Describe(infc) if dsc.spatialReference.Name == "Unknown": print ('skipped this fc due to undefined coord sys: ') print (infc) else: #Determine the new outpurt feature class outfc = os.path.join(outWorkspace, infc) #Set output coord sys outCS = arcpy.SpatialReference('WGS 1984 Web Mercator Auxiliary Sphere') break #Run project tool arcpy.Project_management(infc, outfc, outCS) #Check messages print(arcpy.GetMessages()) except arcpy.ExecuteError: print(arcpy.GetMessages(2)) except Exception as ex: print(ex.args)
ERROR 999999: Error executing function.
The error seems to be at the call to SpatialReference() since I don't get the error when I insert the break above that line. I have tried removing the underscores in the coordinate system name and still get the error. How can I fix this?