AnsweredAssumed Answered

Batch reproject

Question asked by rnr0004 on Mar 23, 2015
Latest reply on Mar 23, 2015 by pcrosier

Trying to get this script to find all .tif and .shp files and reproject them as shown.  Having trouble getting it to run.

 

import sys, arcpy, os

 

mypath = r'C:\input '

Images = []

arcpy.env.workspace = mypath

 

for ThisFile in os.listdir(mypath):

    thisName,thisExt = os.path.splitext(ThisFile)

    if thisExt.upper == ".TIF":

        Images.append(ThisFile)

 

out_workspace = r'C:\output'

OutSR = arcpy.SpatialReference(26916)  

 

for ThisFile in Images:

    desc = arcpy.Describe(ThisFile)

    SR = desc.spatialReference

    if SR.factoryCode != 26916:

        arcpy.ProjectRaster_management(ThisFile,out_workspace + "\\" + ThisFile,OutSR)

 

ShapeFiles = []

for ThisFile in os.listdir(mypath):

    thisName,thisExt = os.path.splitext(ThisFile)

    if thisExt.upper == ".SHP":

        ShapeFiles.append(ThisFile)

 

for ThisFile in ShapeFiles:

    desc = arcpy.Describe(ThisFile)

    SR = desc.spatialReference

    if SR.factoryCode != 26916:

        arcpy.Project_management(ThisFile,out_workspace + "\\" + ThisFile,OutSR)

Outcomes