Redefining point shapefiles in MXD that have no projection and are located in differe

المشرف العام

Administrator
طاقم الإدارة
# Script to use Layers in MXD source file paths to locate and redefine projectionsimport arcpy, glob, os, sys, arcgisscriptingfrom arcpy import env, mappingpath = os.getcwd()env.workspace = pathenv.overwriteOutput = Truemxd = arcpy.mapping.MapDocument("N:\MXDs\_ThomaKL\MXD GPS Valves\GPS_Shapefile_Paths.mxd")for lyr in arcpy.mapping.ListLayers(mxd): if lyr.supports("DATASOURCE"): print lyr.dataSourceprint 'Reading files from ' + lyr.dataSourceos.chdir(path)prjFile=r'C:\\Python27\\Oklahoma_StatePlane_83N_FIPS_3501.prj'x=0z=x+1NoProjCount=0FileList= arcpy.mapping.ListLayers()for File in FileList: desc = arcpy.Describe(File) SR = desc.spatialReference if SR.name == "Unknown": print "Projection of " + str(File) + " is " + SR.name + " so defining projection." f = open('NoProjection.txt', 'a') f.write(str(File)+"\n") f.close() arcpy.DefineProjection_management(File, prjFile) NoProjCount=NoProjCount+1 else: print File + " is projected " + str(SR.name)I have a python script that I have been working on were the script goes into a MXD that has several shapefiles that are in different locations on my network. Again I am trying to use the location of the shapefiles in the MXD to tell python where to look for them and then redefine their projections.. I feel like I am very close but I have hit a road block with it and I was wondering if anyone could help me finish this to get it to work..



أكثر...
 
أعلى