ashleydia

Python Script Help: Batch Describe Projection

Discussion created by ashleydia on Feb 24, 2011
Latest reply on Feb 28, 2011 by rdharles
Hi all,
I got a lot of help in creating a Python scribt that allows me to describe a dataset's projection: http://forums.arcgis.com/threads/23918-Check-Projection-Coordinate-tool-or-script

Now, I'd like to do the same thing in a "batch." Basically, the ugly window that pops up when I right click on my Describe Projection script tool and hit batch won't do. It needs to be a nicer interface and more automated (just like any batch GPTool). Although, I do get the output that I want.

I'm having two problems with my batch describe script:
1. My loop does not work. I am learning Python, so basic concepts elude me. Don't laugh at my code please!
2. I am getting indent errors that I cannot seem to correct.

I also am curious as to why the tool won't automatically batch if I set the script tool's input parameter to be multivalue.

Any help is most appreciated.
Regards, Ashley

import arcpy

#Define message constants so they may be translated easily
unknown_projection = "Unknown"
# Get the feature class to describe
#
featureClass = arcpy.GetParameterAsText(0)
desc = arcpy.Describe(featureClass)
#Loop through each dataset and describe projection.
for dataset in inDatasets:
        try:
            #Describe input dataset to check if a projection is already defined.
            dsc_Dataset = ConversionUtils.gp.Describe(dataset)
            cs_Dataset = dsc_Dataset.SpatialReference
            #Check if a projection is already define for the input dataset.
            if cs_Dataset.Name != unknown_projection:
                ConversionUtils.gp.AddWarning(msgPrjAlreadyDefine)
# Print SpatialReference object properties
SR = desc.spatialReference
print SR.name
# shows results in commandline of IDLE
print SR.exportToString()
# Show results in geoprocessing tool dialog 
arcpy.AddMessage(SR.name)
arcpy.AddMessage(SR.exportToString())

Outcomes