I have been trying to create a Python script that will convert all shape files within a folder from GCS WGS 84 to Web Mercator. Below is the code I have so far but what I'm struggling with is how to iterate thru each of the files while creating a new name for the output (the new projected file in Web Mercator). Any ideas on how I could change this code to make this work? I know I don't have the output parameter right but I think everything else is right.
import arcpy
import glob
inFCFolder = "C:\Data"
def projectToWebM():
for f in glob.glob(r""+ inFCFolder + "\*.shp"):
try:
arcpy.Project_management(f, f + r"\Project\*.shp","PROJCS['WGS_1984_Web_Mercator_Auxiliary_Sphere',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Mercator_Auxiliary_Sphere'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',0.0],PARAMETER['Standard_Parallel_1',0.0],PARAMETER['Auxiliary_Sphere_Type',0.0],UNIT['Meter',1.0]]","#","GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")
except:
print 'Error: Unable to project ' + f
if __name__== '__main__':
projectToWebM()
Best Answer