这是我使用的...它只会为没有投影的栅格文件定义投影。希望能帮助到你。它还会出于质量保证目的而创建文件列表,而不进行投影。
对于您的矢量,它只需要稍微修改一下-FileList = arcpy.ListFeatureClasses()
# Defines projection for all rasters with undefined projection
# CAUTION - make sure you know that the projection you are defining is the correct one
# for all files in the current directory.
#Licence: Creative Commons
#Created by: George Corea; georgec@atgis.com.au, coreagc@gmail.com
import arcpy, glob, os, sys, arcgisscripting
from arcpy import env, mapping
path = os.getcwd()
env.workspace = path
env.overwriteOutput = True
print 'Reading files from ' + path
os.chdir(path)
prjFile=r'C:\\Python26\\GDA_1994_MGA_Zone_55.prj'
x=0
z=x+1
NoProjCount=0
FileList= arcpy.ListRasters()
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)