##Script Name: Multi centroid ##Description: Get centroid of shapefiles ##Created By: Elaine Kuo ##Date: 29/04/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/test1" #Set the output workspace #outWorkspace = sys.argv[2] #Set the workspace. List all of the feature classes in the dataset outWorkspace= "G:/temp" # Create a list of all the features within the workspace. 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 # Work the magic. outFeatureClass = outWorkspace + os.sep + gp.ValidateTableName(featureName, outWorkspace) gp.Toolbox = "Data Management" gp.FeaturetoPoint(fc, outFeatureClass) gp.AddMessage(gp.GetMessages(2)) print gp.GetMessages(2)
Solved! Go to Solution.