Problem with Describe.spatialReference

500
2
02-02-2011 02:59 AM
MartinRick
Occasional Contributor II
Hello,

currently I am working on a script that automatically converts a chosen raster dataset into a GeoTiff and projects it to wgs84 if it is not already uses this coordinate system. Therefore I have to read the spatial reference of my input dataset.
I tried to do this by using the Describe object. The script works just fine as stand-alone application, but when I try to include it to my Toolbox in ArcGis Desktop 10 I get an error Message which says:

<type 'exceptions.RuntimeError'>: DescribeData: Method SpatialReference does not exist

Does anyone have an idea what's wrong with ArcGIS?

Thanks for all replies

Martin
Tags (2)
0 Kudos
2 Replies
AndrewChapkowski
Esri Regular Contributor
I think you mean to use arcpy.Describe(), not DescribeData()

import arcpy

# Create a Describe object from the raster dataset
#
desc = arcpy.Describe("C:/Data/Boulder.img")

# Print some raster dataset properties
# 
print "Band Count:       %d" % desc.bandCount
print "Compression Type: %s" % desc.compressionType
print "Raster Format:    %s" % desc.format

0 Kudos
MartinRick
Occasional Contributor II
HI Andrew,

unfortunately I think the Errormessage just uses the word "DescribeData", but my script uses the describe object in the right way. As I wrote in my first threat, when the script runs as stand-alone everything is fine. I am using the geoprocessor 9.3 an the code looks like this:

describe = gp.Describe(raster)
if describe.SpatialReference.name == "Unknown":
    gp.DefineProjection_management(raster, inputcoord)


Actually I don't know why but it seems to me that the script works now also from the ArcToolbox. Maybe it was just another example of "Reboot your system and everything is fine again".

Thanks for your reply.

Martin
0 Kudos