Python script for changing Feature & Raster projection
I have a number of feature classes and rasters in a folder ('Data') which
need to be projected to WGS84 from another projection and saved on a
geodatabase ('WGS84.gdb'). I started with the script below and succeeded
to print the Spatial Reference descriptions of both features an rasters -
but only until that point.
I get an error code and can't really tell what's wrong with the last part
of the script. I'm also having difficulty incorporating another loop to
make sure the raster files also get projected (using arcpy.project raster
management).
Any suggestions? Thanks!
import arcpy
import os
from arcpy import env
arcpy.env.workspace=r'C:\Data'
arcpy.env.overwriteOutput = True
output=r'C:\Results\WGS84.gdb'
FClist=arcpy.ListFeatureClasses('*','all')
print FClist
for FClist in arcpy.ListFeatureClasses():
dsc=arcpy.Describe(FClist)
if dsc.spatialReference.Name is 'WGS 1984 UTM Zone 32N':
print 'WGS84'
else:
print 'Not WGS84'
outfc= os.path.join(r'C:\Results\WGS84.gdb', FClist)
outCS= arcpy.SpatialReference('WGS 1984 UTM Zone 32N')
arcpy.Project_management(FClist, outfc, 'WGS 1984 UTM Zone 32N')
print 'OK'
No comments:
Post a Comment