# Get the spatial reference of the Feature Class from folder A # Examine all Feature Classes in folder B and report if their # spatial references match the Feature Class in folder A import arcpy arcpy.env.overwriteOutput = True #set up the paths targetFC = arcpy.GetParameterAsText(0) folderToExamine = arcpy.GetParameterAsText(1) #get spatial reference for the target feature class targetDescribe = arcpy.Describe(targetFC) targetSR = targetDescribe.SpatialReference targetSRName = targetSR.Name # Get a list of my feature classes arcpy.env.workspace = folderToExamine listOfFCs = arcpy.ListFeatureClasses() #Loop through the list of FCs for currentFC in listOfFCs: #Read the spatial reference of the current one currentFCDescribe = arcpy.Describe(currentFC) currentFCSR = currentFCDescribe.SpatialReference currentFCSRName = currentFCSR.Name if currentFCSRName != targetSRName: print "Spatial references don't match" else: print "Spatial references do match" if currentFCSRName == targetSRName: continue else: # Determine the new output feature class path and name outCS = currentFC[:-4] +"_projected.shp" #Reproject datasets that are different from target file arcpy.Project_management(currentFC, outCS, targetSR) #Create a message stating which files were projected projFCs = outCS[:-14] +".shp" projFCList = arcpy.ListFeatureClasses(projFCs) x = ", ".join(projFCList) + ", " arcpy.AddMessage("Projected " + str(x))Solved! Go to Solution.
x = ', '.join(twpList)
#Loop through the list of FCs
for currentFC in listOfFCs:
#print currentFC
#Read the spatial reference of the current one
currentFCDescribe = arcpy.Describe(currentFC)
currentFCSR = currentFCDescribe.SpatialReference
currentFCSRName = currentFCSR.Name
#print currentFCSRName
if currentFCSRName != targetSRName:
print "Spatial references don't match"
else:
print "Spatial references do match"
if currentFCSRName == targetSRName:
#skip
continue
else:
outCS = currentFC[:-4] + "_projected.shp"
arcpy.Project_management(currentFC, outCS, targetSR)
projFCList.append(currentFC)
FCList = arcpy.AddMessage("Projected: " + str(projFCList).strip('[]'))