helenak

batch projection not work

Discussion created by helenak on May 8, 2012
System ArcGIS 9.3

Problem
The code below was used but did not work.
Please kindly help if cs is wrong and advise code modification.
Thank you.

##Script Name: Project shapefiles (batch)
##Description: project multiple shapefiles
##Created By: Elaine Kuo
##Date: 08/05/2012

#Import standard library modules
import arcgisscripting
import os

#Create the Geoprocessor object
gp = arcgisscripting.create(9.3)

#Set the input workspace
#GP.workspace = sys.argv[1]
#Set the workspace.
gp.Workspace= "G:/temp"

#Set the output workspace
#outWorkspace = sys.argv[2]
#Set the workspace. List all of the feature classes in the dataset
outWorkspace= "G:/temp/test"

# Set the spatial reference variable
cs = "C:/Program Files/ArcGIS/Coordinate Systems/Geographic Coordinate Systems/World/WGS 1984.prj"

#Get a list of the featureclasses in the input folder
fcs = gp.ListFeatureClasses()

# Loop through every item in the list that was just generated
for fc in fcs:

    # Break out the name, no path or extension, using the describe object.
    desc = gp.describe(fc)
    featureName = desc.name

    # Make featureclasses as layers
    outFeatureClass = outWorkspace + os.sep + gp.ValidateTableName(featureName, outWorkspace)
    gp.Toolbox = "management"
    gp.Project(fc, outFeatureClass, cs)

Outcomes