arcpy.Describe.PixelType returns useless value

12-03-2015 06:11 AM
Status: Open
New Contributor III
in a Python window in ArcGIS 10.3.1...using arcpy.Describe on a raster will yield an appropriate value for the raster format...'S32'...which stands for 32_BIT_SIGNED. The returned value is NOT a valid value for use in other commands, such as CopyRaster, which require the quoted string -- "32_BIT_SIGNED".  

Please...change Describe or change the commnads to honor the returned Describe value. Left hand, right hand, meet each other!

>>> PxT = arcpy.Describe("ec3m070802080201").PixelType

>>> PxT

>>> arcpy.CopyRaster_management("ec3m070802080201", "newRas", "","","","","",PxT)
    Runtime error  Traceback (most recent call last):   
    File "<string>", line 1, in <module>   
    File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\", 
    line 12583, in CopyRaster raise e ExecuteError: ERROR 000800: 
      The value is not a member of 
       1_BIT | 2_BIT | 4_BIT | 8_BIT_UNSIGNED | 
       8_BIT_SIGNED | 16_BIT_UNSIGNED | 
       16_BIT_SIGNED | 32_BIT_UNSIGNED | 
       32_BIT_SIGNED | 32_BIT_FLOAT | 64_BIT.  

>>> arcpy.CopyRaster_management("ec3m070802080201", "newRas", "","","","","","32_BIT_SIGNED")
<Result 'D:\\Data\\ArcGISdefaults\\MyDefault.gdb\\newRas'>
1 Comment


pixel_types = {
"U1": "1_BIT",
"U2": "2_BIT",
"U4": "4_BIT",
"U8": "8_BIT_SIGNED",
"S16": "16_BIT_UNSIGNED",
"U16": "16_BIT_SIGNED",
"S32": "32_BIT_UNSIGNED",
"U32": "32_BIT_SIGNED",
"F32": "32_BIT_FLOAT",
"F64": "64_BIT"

pixel_type = pixel_types[arcpy.Describe("raster").PixelType]
# or
pixel_type = pixel_types[arcpy.da.Describe("raster")["PixelType"]]