I'm trying to reproject a number of shapefiles representing contours from NAD_83_Albers to NAD_83_UTM_Zone_9N using arcpy.BatchProject(), but I have to use python/regex to preserve a particular file architecture. The script works for all practical purposes, however one thing concerns me. When the script finishes, the XML file for the new shapefile points to the location of the original file as the source and lists the old projections instead of the new ones. The script appears to have simply copied the contents of the old XML file into the new XML instead of showing the proper values. When I go into the properties of the shapefile in Arc it says the projection is UTM rather than Albers as it should be, but the XML file does not line up with this. Any ideas?
Here's my code.
import arcpy, os, re rcont = re.compile(".*\contours") inputDir = arcpy.GetParameterAsText(0) outputDir = arcpy.GetParameterAsText(1) for path, dirs, files in os.walk(inputDir): holder = path if rcont.match(holder): splitList = re.split("[\\\]", holder) cell = splitList[4] trimName = splitList[5] featureType = splitList[6] newDir = outputDir + "\\" + cell newDir2 = newDir + "\\" + trimName newDir3 = newDir2 + "\\" + featureType if not os.path.exists(newDir): os.mkdir(newDir) if not os.path.exists(newDir2): os.mkdir(newDir2) if not os.path.exists(newDir3): os.mkdir(newDir3) arcpy.env.workspace = holder fileList = [] for files in arcpy.ListFeatureClasses(): fileList.append(files) res = arcpy.BatchProject_management(fileList, newDir3, sr) if res.maxSeverity == 0: arcpy.AddMessage("projection of all datasets successful") else: arcpy.AddMessage("failed to project one or more datasets")
أكثر...
Here's my code.
import arcpy, os, re rcont = re.compile(".*\contours") inputDir = arcpy.GetParameterAsText(0) outputDir = arcpy.GetParameterAsText(1) for path, dirs, files in os.walk(inputDir): holder = path if rcont.match(holder): splitList = re.split("[\\\]", holder) cell = splitList[4] trimName = splitList[5] featureType = splitList[6] newDir = outputDir + "\\" + cell newDir2 = newDir + "\\" + trimName newDir3 = newDir2 + "\\" + featureType if not os.path.exists(newDir): os.mkdir(newDir) if not os.path.exists(newDir2): os.mkdir(newDir2) if not os.path.exists(newDir3): os.mkdir(newDir3) arcpy.env.workspace = holder fileList = [] for files in arcpy.ListFeatureClasses(): fileList.append(files) res = arcpy.BatchProject_management(fileList, newDir3, sr) if res.maxSeverity == 0: arcpy.AddMessage("projection of all datasets successful") else: arcpy.AddMessage("failed to project one or more datasets")
أكثر...